test(terminal): profile webgl render stages
This commit is contained in:
@@ -222,6 +222,9 @@ async function runScenario(browser, options, viewport) {
|
||||
frameSamples.push(
|
||||
...(await page.evaluate(() => window.__terminalBenchFrames || [])),
|
||||
);
|
||||
const rendererStats = await page.evaluate(() => window.__terminalBench?.webglFrames || []);
|
||||
const cleanProbe = { ...probe };
|
||||
delete cleanProbe.webglFrames;
|
||||
const canvasPixelSmoke = await page.evaluate(() => {
|
||||
const canvas = document.querySelector("canvas.terminal-canvas:not([hidden])");
|
||||
if (!canvas) {
|
||||
@@ -279,7 +282,8 @@ async function runScenario(browser, options, viewport) {
|
||||
elapsedMs,
|
||||
rowsPerSecond: round(options.lines / (elapsedMs / 1000)),
|
||||
frameMs: summarizeSamples(frameSamples),
|
||||
probe,
|
||||
rendererStats: summarizeRendererStats(rendererStats),
|
||||
probe: cleanProbe,
|
||||
pixelSmoke: pixelResult,
|
||||
screenshotPath,
|
||||
};
|
||||
@@ -288,6 +292,43 @@ async function runScenario(browser, options, viewport) {
|
||||
}
|
||||
}
|
||||
|
||||
export function summarizeRendererStats(frames) {
|
||||
if (!Array.isArray(frames) || frames.length === 0) {
|
||||
return { count: 0 };
|
||||
}
|
||||
const numericFields = [
|
||||
"totalMs",
|
||||
"syncDomMs",
|
||||
"backdropMs",
|
||||
"collectMs",
|
||||
"backdropTextureMs",
|
||||
"fallbackCanvasMs",
|
||||
"atlasMs",
|
||||
"atlasUploadMs",
|
||||
"vertexBuildMs",
|
||||
"vertexUploadMs",
|
||||
"drawMs",
|
||||
"cells",
|
||||
"atlasEntries",
|
||||
"atlasInsertions",
|
||||
"atlasResets",
|
||||
];
|
||||
const summary = { count: frames.length };
|
||||
for (const field of numericFields) {
|
||||
const samples = frames
|
||||
.map((frame) => Number(frame[field] || 0))
|
||||
.filter((value) => Number.isFinite(value));
|
||||
summary[field] = summarizeSamples(samples);
|
||||
}
|
||||
summary.fallbackFullCanvasCount = frames.filter(
|
||||
(frame) => Boolean(frame.fallbackFullCanvas),
|
||||
).length;
|
||||
summary.glyphDrawFailedCount = frames.filter(
|
||||
(frame) => Boolean(frame.glyphDrawFailed),
|
||||
).length;
|
||||
return summary;
|
||||
}
|
||||
|
||||
function benchUrl(options) {
|
||||
const url = new URL(options.url);
|
||||
url.searchParams.set("renderer", options.renderer);
|
||||
|
||||
Reference in New Issue
Block a user