Skip to content

Commit 0d51b1c

Browse files
hi-ogawaOpenCode
andcommitted
refactor: retain all browser benchmark results
Co-authored-by: OpenCode <noreply@opencode.ai>
1 parent 82db35d commit 0d51b1c

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

packages/app/benchmark/e2e/benchmark.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ test("benchmarks Chromium WASM inference", async ({ page }) => {
2424

2525
const runButton = page.locator("#run");
2626
for (let index = 0; index < runs; index++) {
27-
await page.evaluate(() => delete window.__demucsBenchmarkResult);
27+
const resultIndex = await page.evaluate(
28+
() => window.__demucsBenchmarkResults?.length ?? 0,
29+
);
2830
await runButton.click();
2931
await expect(runButton).toBeEnabled({ timeout: runTimeout });
30-
const result = await page.evaluate(() => window.__demucsBenchmarkResult!);
32+
const result = await page.evaluate(
33+
(index) => window.__demucsBenchmarkResults![index],
34+
resultIndex,
35+
);
3136
await writeFile(
3237
resolve(root, `data/benchmark/${output}-run-${index}.json`),
3338
JSON.stringify(result, null, 2),

packages/app/src/lib/benchmark.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77

88
declare global {
99
interface Window {
10-
__demucsBenchmarkResult?: BenchmarkResult;
10+
__demucsBenchmarkResults?: BenchmarkResult[];
1111
}
1212
}
1313

@@ -27,7 +27,6 @@ export const benchmark = {
2727
if (!this.enabled) {
2828
return;
2929
}
30-
delete window.__demucsBenchmarkResult;
3130
progress = {
3231
phase: "preparing",
3332
startedAt,
@@ -43,7 +42,7 @@ export const benchmark = {
4342
}
4443
progress = updateRunProgress(progress, event, at);
4544
if (event.type === "finalized") {
46-
window.__demucsBenchmarkResult = {
45+
const result = {
4746
loadMs: progress.models.reduce(
4847
(sum, item) => sum + (item.loadMs ?? 0),
4948
0,
@@ -56,6 +55,7 @@ export const benchmark = {
5655
totalMs: at - progress.startedAt,
5756
chunks: progress.models.flatMap((item) => item.chunkTimings),
5857
};
58+
(window.__demucsBenchmarkResults ??= []).push(result);
5959
progress = null;
6060
}
6161
},

0 commit comments

Comments
 (0)