From b6811ba7c771739f4d7a8f9ce0e2ca0e07da041c Mon Sep 17 00:00:00 2001 From: Matysh Date: Mon, 7 Sep 2026 04:07:19 +0300 Subject: [PATCH] test: stabilize PDF scene performance witness Issue: #53 User-Visible: no --- test/pdf-scene.test.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/pdf-scene.test.mjs b/test/pdf-scene.test.mjs index d4dd06c4..58072609 100644 --- a/test/pdf-scene.test.mjs +++ b/test/pdf-scene.test.mjs @@ -208,7 +208,10 @@ test('current 20-room large-house space builds from the visible geometry cache u largeSpace.rooms, largeRaw.walls, zero.contour, roomOpenings, GRID_STEP_N, cellCm, GRID_PITCH, NORM_W, extras, ); - const started = performance.now(); + // The full suite runs test files concurrently on CI. Measuring wall time here would + // count periods when this worker is descheduled, so use the CPU consumed by the + // scene build itself while keeping the agreed 200 ms product budget unchanged. + const started = process.cpuUsage(); buildPdfPage({ config: largeConfig, rawSpace: largeRaw, space: largeSpace, layout: fixture.layout, sharedWallGeometry, @@ -216,5 +219,7 @@ test('current 20-room large-house space builds from the visible geometry cache u imperial: false, cardTitle: 'House', version: 'test', now: new Date('2026-09-07T00:00:00Z'), t, }); - assert.ok(performance.now() - started < 200); + const elapsed = process.cpuUsage(started); + const elapsedMs = (elapsed.user + elapsed.system) / 1000; + assert.ok(elapsedMs < 200, `PDF scene build used ${elapsedMs.toFixed(1)} ms of CPU`); });