perf(lab): stream sealed spatial playback tracks
This commit is contained in:
@@ -6,6 +6,7 @@ import { createServer } from "vite";
|
||||
|
||||
let server;
|
||||
let fetchM49TgsFullShadowSpatialChunk;
|
||||
let parseM49TgsNpyTrack;
|
||||
|
||||
const resultId = `m49-tgs-full-shadow-${"a".repeat(64)}`;
|
||||
|
||||
@@ -15,7 +16,7 @@ before(async () => {
|
||||
logLevel: "silent",
|
||||
server: { middlewareMode: true },
|
||||
});
|
||||
({ fetchM49TgsFullShadowSpatialChunk } = await server.ssrLoadModule(
|
||||
({ fetchM49TgsFullShadowSpatialChunk, parseM49TgsNpyTrack } = await server.ssrLoadModule(
|
||||
"/src/core/laboratory/m49TgsFullShadow.ts",
|
||||
));
|
||||
});
|
||||
@@ -73,7 +74,7 @@ test("M4.9T5 chunk keeps every missing-LiDAR cell explicitly UNOBSERVED", async
|
||||
assert.deepEqual(new Set(chunk.frames[0].costmap.states), new Set([0]));
|
||||
});
|
||||
|
||||
test("M4.9T5 viewer prefetches 24-frame immutable chunks", async () => {
|
||||
test("M4.9T5 viewer preloads one immutable binary playback pack", async () => {
|
||||
const [source, contract] = await Promise.all([
|
||||
readFile(
|
||||
new URL("../src/workspaces/laboratory/M49TgsFullShadowEvidence.tsx", import.meta.url),
|
||||
@@ -84,12 +85,37 @@ test("M4.9T5 viewer prefetches 24-frame immutable chunks", async () => {
|
||||
"utf8",
|
||||
),
|
||||
]);
|
||||
assert.match(source, /const CHUNK_FRAMES = 24/);
|
||||
assert.match(source, /activeChunkStart \+ CHUNK_FRAMES/);
|
||||
assert.match(source, /fetchM49TgsFullShadowSpatialChunk/);
|
||||
assert.match(source, /fetchM49TgsFullShadowPlaybackPack/);
|
||||
assert.match(source, /playbackProgress/);
|
||||
assert.doesNotMatch(source, /fetchM49TgsFullShadowSpatialChunk/);
|
||||
assert.match(source, /sampleAvailable: spatial\.sampleAvailable/);
|
||||
assert.match(source, /fetchE47SemanticSlamResult/);
|
||||
assert.match(source, /next\.baseM4ResultId !== result\.source\.linkedVisualResultId/);
|
||||
assert.match(source, /semantic=\{semantic \? \{/);
|
||||
assert.match(contract, /linked_semantic_result_id/);
|
||||
assert.match(contract, /missioncore\.m49-tgs-full-shadow-playback\/v1/);
|
||||
});
|
||||
|
||||
function npyFloat32(values, shape) {
|
||||
const shapeText = shape.length === 1 ? `${shape[0]},` : shape.join(", ");
|
||||
const prefixLength = 10;
|
||||
let header = `{'descr': '<f4', 'fortran_order': False, 'shape': (${shapeText}), }`;
|
||||
const padding = (16 - ((prefixLength + header.length + 1) % 16)) % 16;
|
||||
header += " ".repeat(padding) + "\n";
|
||||
const buffer = new ArrayBuffer(prefixLength + header.length + values.length * 4);
|
||||
const bytes = new Uint8Array(buffer);
|
||||
bytes.set([0x93, 0x4e, 0x55, 0x4d, 0x50, 0x59, 1, 0]);
|
||||
new DataView(buffer).setUint16(8, header.length, true);
|
||||
bytes.set(new TextEncoder().encode(header), prefixLength);
|
||||
new Float32Array(buffer, prefixLength + header.length, values.length).set(values);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
test("M4.9T5 parses sealed NPY tracks without JSON point arrays", () => {
|
||||
const parsed = parseM49TgsNpyTrack(
|
||||
npyFloat32([1.25, -2.5, 3.75, 4.5], [2, 2]),
|
||||
"<f4",
|
||||
[2, 2],
|
||||
);
|
||||
assert.deepEqual([...parsed], [1.25, -2.5, 3.75, 4.5]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user