Settle bottom-anchored restores, flush open timings in the probe, record numbers
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
// then:
|
||||
// node tool/chat_perf_probe.mjs build/chat-perf [messages=300] [deltas=200]
|
||||
//
|
||||
// Three phases, each on a fresh page: open the transcript (the frames after the
|
||||
// history reply until the page is quiet), wheel-scroll it up and back down,
|
||||
// Three phases, each on a fresh page: open the transcript (the frames that do
|
||||
// work after the history reply), wheel-scroll it up and back down,
|
||||
// then stream deltas into a new reply. Flutter's own FrameTiming (build,
|
||||
// raster, total) arrives as console lines from tool/chat_perf_fixture.dart.
|
||||
// Prints one JSON report. Headless Chrome rasterises in software, so raster
|
||||
@@ -59,10 +59,10 @@ async function phase(origin, query, drive) {
|
||||
if (recording) frames.push(text.split(' ').slice(1).map(Number));
|
||||
} else if (text.startsWith('PERF_')) {
|
||||
marks.push(text);
|
||||
if (text === 'PERF_HISTORY') historyAt = { at: Date.now(), frame: allFrames.length };
|
||||
if (text === 'PERF_HISTORY') historyAt = { frame: allFrames.length };
|
||||
}
|
||||
if (text.startsWith('PERF_FRAME ')) {
|
||||
allFrames.push({ at: Date.now(), f: text.split(' ').slice(1).map(Number) });
|
||||
allFrames.push({ f: text.split(' ').slice(1).map(Number) });
|
||||
}
|
||||
});
|
||||
const opened = Date.now();
|
||||
@@ -90,28 +90,17 @@ async function phase(origin, query, drive) {
|
||||
const server = await serveBuild(dir);
|
||||
try {
|
||||
const open = await phase(server.origin, `perf=${messages}`, async ({ opened }) => {
|
||||
// The page is quiet once no frame has arrived for a second.
|
||||
// The fixture flushes the timings 2.5 s after the history reply.
|
||||
const end = Date.now() + 20000;
|
||||
for (;;) {
|
||||
const { historyAt, allFrames } = opened();
|
||||
const last = allFrames.at(-1)?.at ?? 0;
|
||||
if (historyAt && Date.now() - Math.max(last, historyAt.at) > 1000) break;
|
||||
if (Date.now() > end) break;
|
||||
await delay(100);
|
||||
}
|
||||
while (!opened().historyAt && Date.now() < end) await delay(100);
|
||||
await delay(3500);
|
||||
const { historyAt, allFrames } = opened();
|
||||
if (!historyAt) return { open: null };
|
||||
const after = allFrames.slice(historyAt.frame);
|
||||
const sum = (i) => +(after.reduce((a, x) => a + x.f[i], 0) / 1000).toFixed(1);
|
||||
return {
|
||||
open: {
|
||||
...stats(after.map((x) => x.f)),
|
||||
buildSumMs: sum(0),
|
||||
totalSumMs: sum(2),
|
||||
// Wall time from the history reply to the last frame of the burst.
|
||||
settleMs: after.length ? after.at(-1).at - historyAt.at : 0,
|
||||
},
|
||||
};
|
||||
// Frames that did work after the history reply: the cost of opening. The
|
||||
// fixture's flush frames do none.
|
||||
const after = allFrames.slice(historyAt.frame).map((x) => x.f).filter((f) => f[0] >= 1000);
|
||||
const sum = (i) => +(after.reduce((a, f) => a + f[i], 0) / 1000).toFixed(1);
|
||||
return { open: { ...stats(after), buildSumMs: sum(0), totalSumMs: sum(2) } };
|
||||
});
|
||||
const scroll = await phase(server.origin, `perf=${messages}`, async ({ page, start, stop }) => {
|
||||
start();
|
||||
@@ -139,3 +128,5 @@ try {
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
// A keep-alive connection can hold the server open after close.
|
||||
process.exit(0);
|
||||
|
||||
Reference in New Issue
Block a user