From 8205951fc38830cd7a63492d6326c82df1d12ae3 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 13:45:07 +0200 Subject: [PATCH 1/9] update-tests --- resources/shared/benchmark.mjs | 4 ++-- resources/shared/step-runner.mjs | 15 ++++----------- resources/shared/step-scheduler.mjs | 13 +++---------- resources/suite-runner.mjs | 9 +++++---- .../dist/src/speedometer-utils/test-runner.mjs | 15 ++++----------- .../dist/src/speedometer-utils/test-runner.mjs | 15 ++++----------- tests/unittests/benchmark-runner.mjs | 2 +- 7 files changed, 23 insertions(+), 50 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index ff6b4e674..b5fd402a3 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -13,8 +13,8 @@ export class BenchmarkStep { this.run = run; } - async runAndRecordStep(params, suite, step, callback) { - const stepRunner = new StepRunner(null, null, params, suite, step, callback); + async runAndRecordStep(params, suite, step) { + const stepRunner = new StepRunner(null, null, params, suite, step); const result = await stepRunner.runStep(); return result; } diff --git a/resources/shared/step-runner.mjs b/resources/shared/step-runner.mjs index 46187a6ba..1b03d270e 100644 --- a/resources/shared/step-runner.mjs +++ b/resources/shared/step-runner.mjs @@ -7,14 +7,12 @@ export class StepRunner { #params; #suite; #step; - #callback; #type; - constructor(frame, page, params, suite, step, callback, type) { + constructor(frame, page, params, suite, step, type) { this.#suite = suite; this.#step = step; this.#params = params; - this.#callback = callback; this.#page = page; this.#frame = frame; this.#type = type; @@ -89,20 +87,15 @@ export class StepRunner { performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel); }; - const report = () => this.#callback(this.#step, syncTime, asyncTime); const schedulerType = this.#suite.type === "async" || this.#params.useAsyncSteps ? "async" : this.#params.measurementMethod; const schedulerClass = STEP_SCHEDULER_LOOKUP[schedulerType]; - const scheduler = new schedulerClass(runSync, measureAsync, report, this.#params); - - return scheduler.start(); + const scheduler = new schedulerClass(runSync, measureAsync, this.#params); + await scheduler.start(); + return { syncTime, asyncTime }; } } export class AsyncStepRunner extends StepRunner { - constructor(frame, page, params, suite, step, callback, type) { - super(frame, page, params, suite, step, callback, type); - } - async _runSyncStep(step, page) { await step.run(page); } diff --git a/resources/shared/step-scheduler.mjs b/resources/shared/step-scheduler.mjs index df7d96a21..c7e74c298 100644 --- a/resources/shared/step-scheduler.mjs +++ b/resources/shared/step-scheduler.mjs @@ -1,8 +1,7 @@ class StepScheduler { - constructor(syncCallback, asyncCallback, reportCallback, params) { + constructor(syncCallback, asyncCallback, params) { this._syncCallback = syncCallback; this._asyncCallback = asyncCallback; - this._reportCallback = reportCallback; this._params = params; } @@ -22,10 +21,7 @@ class RAFStepScheduler extends StepScheduler { requestAnimationFrame(() => { setTimeout(() => { this._asyncCallback(); - setTimeout(async () => { - const result = await this._reportCallback(); - resolve(result); - }, 0); + setTimeout(resolve, 0); }, 0); }); } @@ -43,10 +39,7 @@ class AsyncRAFStepScheduler extends StepScheduler { return; this._asyncCallback(); - setTimeout(async () => { - const results = await this._reportCallback(); - resolve(results); - }, 0); + setTimeout(resolve, 0); }; requestAnimationFrame(async () => { diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index 18f341566..9e15e1c53 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -87,8 +87,9 @@ export class SuiteRunner { const stepRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default"; const stepRunnerClass = STEP_RUNNER_LOOKUP[stepRunnerType]; - const stepRunner = new stepRunnerClass(this.#frame, this.#page, this.#params, this.#suite, step, this._recordTestResults, stepRunnerType); - await stepRunner.runStep(); + const stepRunner = new stepRunnerClass(this.#frame, this.#page, this.#params, this.#suite, step, stepRunnerType); + let { syncTime, asyncTime } = await stepRunner.runStep(); + this._recordTestResults(step, syncTime, asyncTime); } performance.mark(suiteEndLabel); @@ -122,7 +123,7 @@ export class SuiteRunner { }); } - _recordTestResults = async (step, syncTime, asyncTime) => { + async _recordTestResults(step, syncTime, asyncTime) { // Skip reporting updates for the warmup suite. if (this.#suite === WarmupSuite) return; @@ -134,7 +135,7 @@ export class SuiteRunner { }; this.#suiteResults.prepare = this.#prepareTime; this.#suiteResults.total = total; - }; + } async _updateClient(suite = this.#suite) { if (this.#client?.didFinishSuite) diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-runner.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-runner.mjs index 2d816e853..404298beb 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-runner.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-runner.mjs @@ -7,14 +7,12 @@ export class TestRunner { #params; #suite; #test; - #callback; #type; - constructor(frame, page, params, suite, test, callback, type) { + constructor(frame, page, params, suite, test, type) { this.#suite = suite; this.#test = test; this.#params = params; - this.#callback = callback; this.#page = page; this.#frame = frame; this.#type = type; @@ -89,20 +87,15 @@ export class TestRunner { performance.measure(`${suiteName}.${testName}-async`, syncEndLabel, asyncEndLabel); }; - const report = () => this.#callback(this.#test, syncTime, asyncTime); const invokerType = this.#suite.type === "async" || this.#params.useAsyncSteps ? "async" : this.#params.measurementMethod; const invokerClass = TEST_INVOKER_LOOKUP[invokerType]; - const invoker = new invokerClass(runSync, measureAsync, report, this.#params); - - return invoker.start(); + const invoker = new invokerClass(runSync, measureAsync, this.#params); + await invoker.start(); + return { syncTime, asyncTime }; } } export class AsyncTestRunner extends TestRunner { - constructor(frame, page, params, suite, test, callback, type) { - super(frame, page, params, suite, test, callback, type); - } - async _runSyncStep(test, page) { await test.run(page); } diff --git a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-runner.mjs b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-runner.mjs index 52defcb36..88f99da97 100644 --- a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-runner.mjs +++ b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-runner.mjs @@ -6,14 +6,12 @@ export class TestRunner { #params; #suite; #test; - #callback; #type; - constructor(frame, page, params, suite, test, callback, type) { + constructor(frame, page, params, suite, test, type) { this.#suite = suite; this.#test = test; this.#params = params; - this.#callback = callback; this.#page = page; this.#frame = frame; this.#type = type; @@ -85,20 +83,15 @@ export class TestRunner { performance.measure(`${suiteName}.${testName}-async`, syncEndLabel, asyncEndLabel); }; - const report = () => this.#callback(this.#test, syncTime, asyncTime); const invokerType = this.#suite.type === "async" || this.#params.useAsyncSteps ? "async" : this.#params.measurementMethod; const invokerClass = TEST_INVOKER_LOOKUP[invokerType]; - const invoker = new invokerClass(runSync, measureAsync, report, this.#params); - - return invoker.start(); + const invoker = new invokerClass(runSync, measureAsync, this.#params); + await invoker.start(); + return { syncTime, asyncTime }; } } export class AsyncTestRunner extends TestRunner { - constructor(frame, page, params, suite, test, callback, type) { - super(frame, page, params, suite, test, callback, type); - } - async _runSyncStep(test, page) { await test.run(page); } diff --git a/tests/unittests/benchmark-runner.mjs b/tests/unittests/benchmark-runner.mjs index 928ab8452..df4047153 100644 --- a/tests/unittests/benchmark-runner.mjs +++ b/tests/unittests/benchmark-runner.mjs @@ -147,7 +147,7 @@ describe("BenchmarkRunner", () => { before(async () => { _prepareSuiteSpy = spy(SuiteRunner.prototype, "_prepareSuite"); _loadFrameStub = stub(SuiteRunner.prototype, "_loadFrame").callsFake(async () => null); - _runTestStub = stub(StepRunner.prototype, "runStep").callsFake(async () => null); + _runTestStub = stub(StepRunner.prototype, "runStep").callsFake(async () => ({ syncTime: 0, asyncTime: 0 })); _validateSuiteResultsStub = stub(SuiteRunner.prototype, "_validateSuiteResults").callsFake(async () => null); performanceMarkSpy = spy(window.performance, "mark"); _suitePrepareSpy = spy(suite, "prepare"); From 33251c021d49447cfd7e160cc3c6f1596164df2f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 13:53:56 +0200 Subject: [PATCH 2/9] fix --- .../dist/src/speedometer-utils/benchmark.mjs | 4 +- .../src/speedometer-utils/benchmark.mjs | 4 +- .../dist/src/speedometer-utils/benchmark.mjs | 4 +- tests/unittests/benchmark-runner.mjs | 56 +++++++++++++++++-- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs index 264145159..af44ad738 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs @@ -14,10 +14,10 @@ export class BenchmarkStep { this.ignoreResult = ignoreResult; } - async runAndRecord(params, suite, test, callback) { + async runAndRecord(params, suite, test) { const TestRunnerClass = params.useAsyncSteps ? AsyncTestRunner : TestRunner; const type = params.useAsyncSteps ? "async" : "sync"; - const testRunner = new TestRunnerClass(null, null, params, suite, test, callback, type); + const testRunner = new TestRunnerClass(null, null, params, suite, test, type); const result = await testRunner.runTest(); return result; } diff --git a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs index a16f0831f..cb620dafc 100644 --- a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs @@ -14,10 +14,10 @@ export class BenchmarkStep { this.ignoreResult = ignoreResult; } - async runAndRecord(params, suite, test, callback) { + async runAndRecord(params, suite, test) { const TestRunnerClass = params.useAsyncSteps ? AsyncTestRunner : TestRunner; const type = params.useAsyncSteps ? "async" : "sync"; - const testRunner = new TestRunnerClass(null, null, params, suite, test, callback, type); + const testRunner = new TestRunnerClass(null, null, params, suite, test, type); const result = await testRunner.runTest(); return result; } diff --git a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs index b691e86ac..b790ea07e 100644 --- a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs +++ b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs @@ -13,8 +13,8 @@ export class BenchmarkStep { this.run = run; } - async runAndRecord(params, suite, test, callback) { - const testRunner = new TestRunner(null, null, params, suite, test, callback); + async runAndRecord(params, suite, test) { + const testRunner = new TestRunner(null, null, params, suite, test); const result = await testRunner.runTest(); return result; } diff --git a/tests/unittests/benchmark-runner.mjs b/tests/unittests/benchmark-runner.mjs index df4047153..67510200b 100644 --- a/tests/unittests/benchmark-runner.mjs +++ b/tests/unittests/benchmark-runner.mjs @@ -1,6 +1,7 @@ -import { BenchmarkRunner } from "../../resources/benchmark-runner.mjs"; +import { BenchmarkRunner, BenchmarkTestStep } from "../../resources/benchmark-runner.mjs"; import { SuiteRunner } from "../../resources/suite-runner.mjs"; -import { StepRunner } from "../../resources/shared/step-runner.mjs"; +import { StepRunner, AsyncStepRunner } from "../../resources/shared/step-runner.mjs"; +import { STEP_SCHEDULER_LOOKUP } from "../../resources/shared/step-scheduler.mjs"; import { defaultParams } from "../../resources/shared/params.mjs"; function TEST_FIXTURE(name) { @@ -109,8 +110,7 @@ describe("BenchmarkRunner", () => { _loadFrameStub = stub(SuiteRunner.prototype, "_loadFrame").callsFake(async () => null); _appendFrameStub = stub(runner, "_appendFrame").callsFake(async () => null); _removeFrameStub = stub(runner, "_removeFrame").callsFake(() => null); - for (const suite of runner._suites) - spy(suite, "prepare"); + runner._suites.forEach((suite) => spy(suite, "prepare")); expect(runner._suites).not.to.have.length(0); await runner.runAllSuites(); }); @@ -256,4 +256,52 @@ describe("BenchmarkRunner", () => { }); }); }); + + describe("StepRunner", () => { + const suite = SUITES_FIXTURE[0]; + const params = { measurementMethod: "raf", warmupBeforeSync: 0 }; + + it("should run StepRunner and return { syncTime, asyncTime }", async () => { + const step = new BenchmarkTestStep("SyncStep", sinon.stub()); + const runner = new StepRunner(null, null, params, suite, step, "default"); + const { syncTime, asyncTime } = await runner.runStep(); + expect(typeof syncTime).to.equal("number"); + expect(typeof asyncTime).to.equal("number"); + assert.calledOnce(step.run); + }); + + it("should run AsyncStepRunner and return { syncTime, asyncTime }", async () => { + const asyncStep = new BenchmarkTestStep( + "AsyncStep", + sinon.stub().callsFake(async () => {}) + ); + const runner = new AsyncStepRunner(null, null, params, suite, asyncStep, "async"); + const { syncTime, asyncTime } = await runner.runStep(); + expect(typeof syncTime).to.equal("number"); + expect(typeof asyncTime).to.equal("number"); + assert.calledOnce(asyncStep.run); + }); + }); + + describe("StepScheduler", () => { + it("should schedule callbacks and resolve in RAFStepScheduler", async () => { + const syncCallback = sinon.stub(); + const asyncCallback = sinon.stub(); + const scheduler = new STEP_SCHEDULER_LOOKUP.raf(syncCallback, asyncCallback, { waitBeforeSync: 0 }); + const result = await scheduler.start(); + expect(result).to.be(undefined); + assert.calledOnce(syncCallback); + assert.calledOnce(asyncCallback); + }); + + it("should respect waitBeforeSync when starting scheduler", async () => { + const syncCallback = sinon.stub(); + const asyncCallback = sinon.stub(); + const scheduler = new STEP_SCHEDULER_LOOKUP.raf(syncCallback, asyncCallback, { waitBeforeSync: 10 }); + const result = await scheduler.start(); + expect(result).to.be(undefined); + assert.calledOnce(syncCallback); + assert.calledOnce(asyncCallback); + }); + }); }); From 9578719c6e8ec9bff959386a34a294a7d357cf2a Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 14:50:43 +0200 Subject: [PATCH 3/9] fix-utils --- .../dist/src/speedometer-utils/test-invoker.mjs | 13 +++---------- .../dist/src/speedometer-utils/test-invoker.mjs | 8 ++------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-invoker.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-invoker.mjs index cb63c3de3..8fd881e6f 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-invoker.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/test-invoker.mjs @@ -1,8 +1,7 @@ class TestInvoker { - constructor(syncCallback, asyncCallback, reportCallback, params) { + constructor(syncCallback, asyncCallback, params) { this._syncCallback = syncCallback; this._asyncCallback = asyncCallback; - this._reportCallback = reportCallback; this._params = params; } @@ -22,10 +21,7 @@ class RAFTestInvoker extends TestInvoker { requestAnimationFrame(() => { setTimeout(() => { this._asyncCallback(); - setTimeout(async () => { - const result = await this._reportCallback(); - resolve(result); - }, 0); + setTimeout(resolve, 0); }, 0); }); } @@ -43,10 +39,7 @@ class AsyncRAFTestInvoker extends TestInvoker { return; this._asyncCallback(); - setTimeout(async () => { - const results = await this._reportCallback(); - resolve(results); - }, 0); + setTimeout(resolve, 0); }; requestAnimationFrame(async () => { diff --git a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-invoker.mjs b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-invoker.mjs index 7bf105bdc..68d0aafc5 100644 --- a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-invoker.mjs +++ b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/test-invoker.mjs @@ -1,8 +1,7 @@ class TestInvoker { - constructor(syncCallback, asyncCallback, reportCallback, params) { + constructor(syncCallback, asyncCallback, params) { this._syncCallback = syncCallback; this._asyncCallback = asyncCallback; - this._reportCallback = reportCallback; this._params = params; } } @@ -24,10 +23,7 @@ class RAFTestInvoker extends BaseRAFTestInvoker { requestAnimationFrame(() => { setTimeout(() => { this._asyncCallback(); - setTimeout(async () => { - const result = await this._reportCallback(); - resolve(result); - }, 0); + setTimeout(resolve, 0); }, 0); }); } From 8e46d998f5242218170315903ec190cf65f37393 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 15:10:10 +0200 Subject: [PATCH 4/9] fx --- resources/shared/benchmark.mjs | 23 ++++++++----------- .../dist/src/speedometer-utils/benchmark.mjs | 9 ++++++-- .../src/speedometer-utils/benchmark.mjs | 9 ++++++-- .../dist/src/speedometer-utils/benchmark.mjs | 13 ++++++++--- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index b5fd402a3..8799dca27 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -31,16 +31,6 @@ export class BenchmarkSuite { this.steps = steps; } - record(_step, syncTime, asyncTime) { - const total = syncTime + asyncTime; - const results = { - tests: { Sync: syncTime, Async: asyncTime }, - total: total, - }; - - return results; - } - async runAndRecordSuite(params, onProgress) { const measuredValues = { tests: {}, @@ -53,9 +43,16 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const step of this.steps) { - const result = await step.runAndRecordStep(params, this, step, this.record); - measuredValues.tests[step.name] = result; - measuredValues.total += result.total; + const { syncTime, asyncTime } = await step.runAndRecordStep(params, this, step); + const total = syncTime + asyncTime; + const result = { + tests: { Sync: syncTime, Async: asyncTime }, + total: total, + }; + if (!step.ignoreResult) { + measuredValues.tests[step.name] = result; + measuredValues.total += total; + } onProgress?.(step.name); } diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs index af44ad738..051315b8d 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs @@ -55,10 +55,15 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const test of this.tests) { - const result = await test.runAndRecord(params, this, test, this.record); + const { syncTime, asyncTime } = await test.runAndRecord(params, this, test); + const total = syncTime + asyncTime; + const result = { + tests: { Sync: syncTime, Async: asyncTime }, + total: total, + }; if (!test.ignoreResult) { measuredValues.tests[test.name] = result; - measuredValues.total += result.total; + measuredValues.total += total; } onProgress?.(test.name); } diff --git a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs index cb620dafc..eee4b955c 100644 --- a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs @@ -55,10 +55,15 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const test of this.tests) { - const result = await test.runAndRecord(params, this, test, this.record); + const { syncTime, asyncTime } = await test.runAndRecord(params, this, test); + const total = syncTime + asyncTime; + const result = { + tests: { Sync: syncTime, Async: asyncTime }, + total: total, + }; if (!test.ignoreResult) { measuredValues.tests[test.name] = result; - measuredValues.total += result.total; + measuredValues.total += total; } onProgress?.(test.name); } diff --git a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs index b790ea07e..65dbd6d81 100644 --- a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs +++ b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs @@ -52,9 +52,16 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const test of this.tests) { - const result = await test.runAndRecord(params, this, test, this.record); - measuredValues.tests[test.name] = result; - measuredValues.total += result.total; + const { syncTime, asyncTime } = await test.runAndRecord(params, this, test); + const total = syncTime + asyncTime; + const result = { + tests: { Sync: syncTime, Async: asyncTime }, + total: total, + }; + if (!test.ignoreResult) { + measuredValues.tests[test.name] = result; + measuredValues.total += total; + } onProgress?.(test.name); } From 5395de1951ec2eab7069750de573318471fbbaaa Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 16:35:52 +0200 Subject: [PATCH 5/9] merge-main --- resources/shared/benchmark.mjs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index 0ef290389..079a3179b 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -59,8 +59,9 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const step of this.steps) { -<<<<<<< HEAD - const { syncTime, asyncTime } = await step.runAndRecordStep(params, this, step); + const rawResult = await step.runAndRecordStep(params, this, step); + console.assert(rawResult, "Missing test return value", step); + const { syncTime, asyncTime } = rawResult; const total = syncTime + asyncTime; const result = { tests: { Sync: syncTime, Async: asyncTime }, @@ -70,12 +71,6 @@ export class BenchmarkSuite { measuredValues.tests[step.name] = result; measuredValues.total += total; } -======= - const result = await step.runAndRecordStep(params, this, step, this.record); - console.assert(result, "Missing test return value", step); - measuredValues.tests[step.name] = result; - measuredValues.total += result.total; ->>>>>>> main onProgress?.(step.name); } From 053ffa6c13c03853b254933ac0591375c79d8b05 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 16:37:59 +0200 Subject: [PATCH 6/9] clenaup --- resources/shared/benchmark.mjs | 6 ++-- resources/shared/step-runner.mjs | 12 +++---- resources/shared/step-scheduler.mjs | 9 ++--- resources/suite-runner.mjs | 33 +++++++------------ .../src/speedometer-utils/step-runner.mjs | 12 +++---- .../src/speedometer-utils/step-scheduler.mjs | 9 ++--- 6 files changed, 27 insertions(+), 54 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index 079a3179b..7ee92342d 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -122,8 +122,7 @@ export class BenchmarkConnector { this.name = name; this.version = version; - if (!name || !version) - console.warn("No name or version supplied, to create a unique appId"); + if (!name || !version) console.warn("No name or version supplied, to create a unique appId"); this.appId = name && version ? `${name}-${version}` : -1; this.onMessage = this.onMessage.bind(this); @@ -141,8 +140,7 @@ export class BenchmarkConnector { const params = new Params(new URLSearchParams(window.location.search)); const { name } = message.payload; const suite = this.suites[name]; - if (!suite) - console.error(`Suite with the name of "${name}" not found!`); + if (!suite) console.error(`Suite with the name of "${name}" not found!`); const onProgress = (step) => this._sendMessage(MESSAGE_TYPE.stepComplete, { name: this.name, step }); const { result } = await suite.runAndRecordSuite(params, onProgress); this._sendMessage(MESSAGE_TYPE.suiteComplete, { result }); diff --git a/resources/shared/step-runner.mjs b/resources/shared/step-runner.mjs index 1b03d270e..a683c3437 100644 --- a/resources/shared/step-runner.mjs +++ b/resources/shared/step-runner.mjs @@ -47,17 +47,14 @@ export class StepRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) - continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); const syncStartTime = performance.now(); - if (this.#type === "async") - await this._runSyncStep(this.step, this.page); - else - this._runSyncStep(this.step, this.page); + if (this.#type === "async") await this._runSyncStep(this.step, this.page); + else this._runSyncStep(this.step, this.page); const mark = performance.mark(syncEndLabel); const syncEndTime = mark.startTime; @@ -81,8 +78,7 @@ export class StepRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) - performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${stepName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel); }; diff --git a/resources/shared/step-scheduler.mjs b/resources/shared/step-scheduler.mjs index c7e74c298..182704bcb 100644 --- a/resources/shared/step-scheduler.mjs +++ b/resources/shared/step-scheduler.mjs @@ -7,10 +7,8 @@ class StepScheduler { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) - setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else - this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else this._scheduleCallbacks(resolve); }); } } @@ -35,8 +33,7 @@ class AsyncRAFStepScheduler extends StepScheduler { let gotPromise = false; const tryTriggerAsyncCallback = () => { - if (!gotTimer || !gotMessage || !gotPromise) - return; + if (!gotTimer || !gotMessage || !gotPromise) return; this._asyncCallback(); setTimeout(resolve, 0); diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index 9b0084392..db850fc1d 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -3,8 +3,7 @@ import { MESSAGE_TYPE } from "./shared/benchmark.mjs"; import { WarmupSuite } from "./benchmark-runner.mjs"; function delay(ms) { - if (ms > 0) - return new Promise((resolve) => setTimeout(resolve, ms)); + if (ms > 0) return new Promise((resolve) => setTimeout(resolve, ms)); return undefined; } @@ -83,8 +82,7 @@ export class SuiteRunner { performance.mark(suiteStartLabel); for (const step of this.#suite.tests) { - if (this.#client?.willRunTest) - await this.#client.willRunTest(this.#suite, step); + if (this.#client?.willRunTest) await this.#client.willRunTest(this.#suite, step); const stepRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default"; const stepRunnerClass = STEP_RUNNER_LOOKUP[stepRunnerType]; @@ -106,10 +104,8 @@ export class SuiteRunner { // privacy.resistFingerprinting preference), it's possible that the measured // total duration for an entire is 0. const { suiteTotal, suitePrepare } = this.#suiteResults.total; - if (suiteTotal === 0) - throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); - if (this.#params.measurePrepare && suitePrepare === 0) - throw new Error(`Got invalid 0-time prepare time for suite ${this.#suite.name}: ${suitePrepare}`); + if (suiteTotal === 0) throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); + if (this.#params.measurePrepare && suitePrepare === 0) throw new Error(`Got invalid 0-time prepare time for suite ${this.#suite.name}: ${suitePrepare}`); } async _loadFrame() { @@ -118,16 +114,14 @@ export class SuiteRunner { frame.onload = () => resolve(); frame.onerror = () => reject(); const url = new URL(this.#suite.url, document.baseURI); - for (const [key, value] of this.#params.toSearchParamsObject()) - url.searchParams.append(key, value); + for (const [key, value] of this.#params.toSearchParamsObject()) url.searchParams.append(key, value); frame.src = url.href; }); } async _recordTestResults(step, syncTime, asyncTime) { // Skip reporting updates for the warmup suite. - if (this.#suite === WarmupSuite) - return; + if (this.#suite === WarmupSuite) return; let total = syncTime + asyncTime; this.#suiteResults.tests[step.name] = { @@ -139,8 +133,7 @@ export class SuiteRunner { } async _updateClient(suite = this.#suite) { - if (this.#client?.didFinishSuite) - await this.#client.didFinishSuite(suite); + if (this.#client?.didFinishSuite) await this.#client.didFinishSuite(suite); } } @@ -224,20 +217,17 @@ export class RemoteSuiteRunner extends SuiteRunner { _handlePostMessage(event) { const message = event.data; const callback = this.postMessageCallbacks.get(message.type); - if (callback) - callback(event); + if (callback) callback(event); } _startSubscription(type, callback) { - if (this.postMessageCallbacks.has(type)) - throw new Error("Callback exists already"); + if (this.postMessageCallbacks.has(type)) throw new Error("Callback exists already"); this.postMessageCallbacks.set(type, callback); } _stopSubscription(type) { - if (!this.postMessageCallbacks.has(type)) - throw new Error("Callback does not exist"); + if (!this.postMessageCallbacks.has(type)) throw new Error("Callback does not exist"); this.postMessageCallbacks.delete(type); } @@ -246,8 +236,7 @@ export class RemoteSuiteRunner extends SuiteRunner { return new Promise((resolve) => { this._startSubscription(type, (e) => { const message = e.data; - if (type !== MESSAGE_TYPE.appReady && message.appId !== this.appId) - throw new Error(`Got message for invalid app: ${message.appId} instead of ${this.appId}`); + if (type !== MESSAGE_TYPE.appReady && message.appId !== this.appId) throw new Error(`Got message for invalid app: ${message.appId} instead of ${this.appId}`); this._stopSubscription(type); resolve(message.payload); }); diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs index 1b03d270e..a683c3437 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs @@ -47,17 +47,14 @@ export class StepRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) - continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); const syncStartTime = performance.now(); - if (this.#type === "async") - await this._runSyncStep(this.step, this.page); - else - this._runSyncStep(this.step, this.page); + if (this.#type === "async") await this._runSyncStep(this.step, this.page); + else this._runSyncStep(this.step, this.page); const mark = performance.mark(syncEndLabel); const syncEndTime = mark.startTime; @@ -81,8 +78,7 @@ export class StepRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) - performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${stepName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel); }; diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs index c7e74c298..182704bcb 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs @@ -7,10 +7,8 @@ class StepScheduler { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) - setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else - this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else this._scheduleCallbacks(resolve); }); } } @@ -35,8 +33,7 @@ class AsyncRAFStepScheduler extends StepScheduler { let gotPromise = false; const tryTriggerAsyncCallback = () => { - if (!gotTimer || !gotMessage || !gotPromise) - return; + if (!gotTimer || !gotMessage || !gotPromise) return; this._asyncCallback(); setTimeout(resolve, 0); From 2f438bc4e3eabfeed62ebf00d3f28c3a8085d718 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 16:40:00 +0200 Subject: [PATCH 7/9] fx --- .../src/speedometer-utils/benchmark.mjs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs index 0b68d276c..61f34c454 100644 --- a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs @@ -14,19 +14,11 @@ export class BenchmarkStep { this.ignoreResult = ignoreResult; } -<<<<<<< HEAD async runAndRecord(params, suite, test) { - const TestRunnerClass = params.useAsyncSteps ? AsyncTestRunner : TestRunner; - const type = params.useAsyncSteps ? "async" : "sync"; - const testRunner = new TestRunnerClass(null, null, params, suite, test, type); - const result = await testRunner.runTest(); -======= - async runAndRecord(params, suite, test, callback) { const StepRunnerClass = params.useAsyncSteps ? AsyncStepRunner : StepRunner; const type = params.useAsyncSteps ? "async" : "sync"; - const stepRunner = new StepRunnerClass(null, null, params, suite, test, callback, type); + const stepRunner = new StepRunnerClass(null, null, params, suite, test, type); const result = await stepRunner.runStep(); ->>>>>>> main return result; } } From 1fa3b36151f043f00b43ac53dc0b4dcf431feb8e Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 14 Jul 2026 16:41:05 +0200 Subject: [PATCH 8/9] formatting --- resources/shared/benchmark.mjs | 6 ++++-- resources/shared/step-runner.mjs | 12 +++++++---- resources/shared/step-scheduler.mjs | 9 +++++--- resources/suite-runner.mjs | 33 +++++++++++++++++++---------- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index 7ee92342d..079a3179b 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -122,7 +122,8 @@ export class BenchmarkConnector { this.name = name; this.version = version; - if (!name || !version) console.warn("No name or version supplied, to create a unique appId"); + if (!name || !version) + console.warn("No name or version supplied, to create a unique appId"); this.appId = name && version ? `${name}-${version}` : -1; this.onMessage = this.onMessage.bind(this); @@ -140,7 +141,8 @@ export class BenchmarkConnector { const params = new Params(new URLSearchParams(window.location.search)); const { name } = message.payload; const suite = this.suites[name]; - if (!suite) console.error(`Suite with the name of "${name}" not found!`); + if (!suite) + console.error(`Suite with the name of "${name}" not found!`); const onProgress = (step) => this._sendMessage(MESSAGE_TYPE.stepComplete, { name: this.name, step }); const { result } = await suite.runAndRecordSuite(params, onProgress); this._sendMessage(MESSAGE_TYPE.suiteComplete, { result }); diff --git a/resources/shared/step-runner.mjs b/resources/shared/step-runner.mjs index a683c3437..1b03d270e 100644 --- a/resources/shared/step-runner.mjs +++ b/resources/shared/step-runner.mjs @@ -47,14 +47,17 @@ export class StepRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) + continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); const syncStartTime = performance.now(); - if (this.#type === "async") await this._runSyncStep(this.step, this.page); - else this._runSyncStep(this.step, this.page); + if (this.#type === "async") + await this._runSyncStep(this.step, this.page); + else + this._runSyncStep(this.step, this.page); const mark = performance.mark(syncEndLabel); const syncEndTime = mark.startTime; @@ -78,7 +81,8 @@ export class StepRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) + performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${stepName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel); }; diff --git a/resources/shared/step-scheduler.mjs b/resources/shared/step-scheduler.mjs index 182704bcb..c7e74c298 100644 --- a/resources/shared/step-scheduler.mjs +++ b/resources/shared/step-scheduler.mjs @@ -7,8 +7,10 @@ class StepScheduler { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) + setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else + this._scheduleCallbacks(resolve); }); } } @@ -33,7 +35,8 @@ class AsyncRAFStepScheduler extends StepScheduler { let gotPromise = false; const tryTriggerAsyncCallback = () => { - if (!gotTimer || !gotMessage || !gotPromise) return; + if (!gotTimer || !gotMessage || !gotPromise) + return; this._asyncCallback(); setTimeout(resolve, 0); diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index db850fc1d..9b0084392 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -3,7 +3,8 @@ import { MESSAGE_TYPE } from "./shared/benchmark.mjs"; import { WarmupSuite } from "./benchmark-runner.mjs"; function delay(ms) { - if (ms > 0) return new Promise((resolve) => setTimeout(resolve, ms)); + if (ms > 0) + return new Promise((resolve) => setTimeout(resolve, ms)); return undefined; } @@ -82,7 +83,8 @@ export class SuiteRunner { performance.mark(suiteStartLabel); for (const step of this.#suite.tests) { - if (this.#client?.willRunTest) await this.#client.willRunTest(this.#suite, step); + if (this.#client?.willRunTest) + await this.#client.willRunTest(this.#suite, step); const stepRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default"; const stepRunnerClass = STEP_RUNNER_LOOKUP[stepRunnerType]; @@ -104,8 +106,10 @@ export class SuiteRunner { // privacy.resistFingerprinting preference), it's possible that the measured // total duration for an entire is 0. const { suiteTotal, suitePrepare } = this.#suiteResults.total; - if (suiteTotal === 0) throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); - if (this.#params.measurePrepare && suitePrepare === 0) throw new Error(`Got invalid 0-time prepare time for suite ${this.#suite.name}: ${suitePrepare}`); + if (suiteTotal === 0) + throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); + if (this.#params.measurePrepare && suitePrepare === 0) + throw new Error(`Got invalid 0-time prepare time for suite ${this.#suite.name}: ${suitePrepare}`); } async _loadFrame() { @@ -114,14 +118,16 @@ export class SuiteRunner { frame.onload = () => resolve(); frame.onerror = () => reject(); const url = new URL(this.#suite.url, document.baseURI); - for (const [key, value] of this.#params.toSearchParamsObject()) url.searchParams.append(key, value); + for (const [key, value] of this.#params.toSearchParamsObject()) + url.searchParams.append(key, value); frame.src = url.href; }); } async _recordTestResults(step, syncTime, asyncTime) { // Skip reporting updates for the warmup suite. - if (this.#suite === WarmupSuite) return; + if (this.#suite === WarmupSuite) + return; let total = syncTime + asyncTime; this.#suiteResults.tests[step.name] = { @@ -133,7 +139,8 @@ export class SuiteRunner { } async _updateClient(suite = this.#suite) { - if (this.#client?.didFinishSuite) await this.#client.didFinishSuite(suite); + if (this.#client?.didFinishSuite) + await this.#client.didFinishSuite(suite); } } @@ -217,17 +224,20 @@ export class RemoteSuiteRunner extends SuiteRunner { _handlePostMessage(event) { const message = event.data; const callback = this.postMessageCallbacks.get(message.type); - if (callback) callback(event); + if (callback) + callback(event); } _startSubscription(type, callback) { - if (this.postMessageCallbacks.has(type)) throw new Error("Callback exists already"); + if (this.postMessageCallbacks.has(type)) + throw new Error("Callback exists already"); this.postMessageCallbacks.set(type, callback); } _stopSubscription(type) { - if (!this.postMessageCallbacks.has(type)) throw new Error("Callback does not exist"); + if (!this.postMessageCallbacks.has(type)) + throw new Error("Callback does not exist"); this.postMessageCallbacks.delete(type); } @@ -236,7 +246,8 @@ export class RemoteSuiteRunner extends SuiteRunner { return new Promise((resolve) => { this._startSubscription(type, (e) => { const message = e.data; - if (type !== MESSAGE_TYPE.appReady && message.appId !== this.appId) throw new Error(`Got message for invalid app: ${message.appId} instead of ${this.appId}`); + if (type !== MESSAGE_TYPE.appReady && message.appId !== this.appId) + throw new Error(`Got message for invalid app: ${message.appId} instead of ${this.appId}`); this._stopSubscription(type); resolve(message.payload); }); From bc98fe8b7ea271c72cc67e5719f798228085af71 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 16 Jul 2026 09:42:19 +0200 Subject: [PATCH 9/9] Resolve merge conflicts and update speedometer-utils dist in suites --- resources/shared/benchmark.mjs | 6 +++--- .../dist/src/speedometer-utils/benchmark.mjs | 19 +------------------ .../src/speedometer-utils/step-runner.mjs | 12 ++++++++---- .../src/speedometer-utils/step-scheduler.mjs | 9 ++++++--- .../src/speedometer-utils/benchmark.mjs | 10 ---------- .../dist/src/speedometer-utils/benchmark.mjs | 17 ++++++----------- 6 files changed, 24 insertions(+), 49 deletions(-) diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index 079a3179b..3398729f4 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -21,9 +21,9 @@ export class BenchmarkStep { } export class AsyncBenchmarkStep extends BenchmarkStep { - async runAndRecord(params, suite, test, callback) { - const testRunner = new AsyncStepRunner(null, null, params, suite, test, callback); - const result = await testRunner.runTest(); + async runAndRecordStep(params, suite, step) { + const stepRunner = new AsyncStepRunner(null, null, params, suite, step); + const result = await stepRunner.runStep(); return result; } } diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs index 5e5b55708..b2e219dae 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/benchmark.mjs @@ -14,19 +14,11 @@ export class BenchmarkStep { this.ignoreResult = ignoreResult; } -<<<<<<< HEAD async runAndRecord(params, suite, test) { - const TestRunnerClass = params.useAsyncSteps ? AsyncTestRunner : TestRunner; - const type = params.useAsyncSteps ? "async" : "sync"; - const testRunner = new TestRunnerClass(null, null, params, suite, test, type); - const result = await testRunner.runTest(); -======= - async runAndRecord(params, suite, test, callback) { const StepRunnerClass = params.useAsyncSteps ? AsyncStepRunner : StepRunner; const type = params.useAsyncSteps ? "async" : "sync"; - const stepRunner = new StepRunnerClass(null, null, params, suite, test, callback, type); + const stepRunner = new StepRunnerClass(null, null, params, suite, test, type); const result = await stepRunner.runStep(); ->>>>>>> main return result; } } @@ -42,15 +34,6 @@ export class BenchmarkSuite { this.tests = tests; } - record(_test, syncTime, asyncTime) { - const total = syncTime + asyncTime; - const results = { - tests: { Sync: syncTime, Async: asyncTime }, - total: total, - }; - - return results; - } async runAndRecord(params, onProgress) { const measuredValues = { diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs index a683c3437..1b03d270e 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-runner.mjs @@ -47,14 +47,17 @@ export class StepRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) + continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); const syncStartTime = performance.now(); - if (this.#type === "async") await this._runSyncStep(this.step, this.page); - else this._runSyncStep(this.step, this.page); + if (this.#type === "async") + await this._runSyncStep(this.step, this.page); + else + this._runSyncStep(this.step, this.page); const mark = performance.mark(syncEndLabel); const syncEndTime = mark.startTime; @@ -78,7 +81,8 @@ export class StepRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) + performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${stepName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel); }; diff --git a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs index 182704bcb..c7e74c298 100644 --- a/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs +++ b/suites-experimental/javascript-wc-indexeddb/dist/src/speedometer-utils/step-scheduler.mjs @@ -7,8 +7,10 @@ class StepScheduler { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) + setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else + this._scheduleCallbacks(resolve); }); } } @@ -33,7 +35,8 @@ class AsyncRAFStepScheduler extends StepScheduler { let gotPromise = false; const tryTriggerAsyncCallback = () => { - if (!gotTimer || !gotMessage || !gotPromise) return; + if (!gotTimer || !gotMessage || !gotPromise) + return; this._asyncCallback(); setTimeout(resolve, 0); diff --git a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs index 61f34c454..f5595ed6e 100644 --- a/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs +++ b/suites-experimental/javascript-wc-indexeddb/src/speedometer-utils/benchmark.mjs @@ -34,16 +34,6 @@ export class BenchmarkSuite { this.tests = tests; } - record(_test, syncTime, asyncTime) { - const total = syncTime + asyncTime; - const results = { - tests: { Sync: syncTime, Async: asyncTime }, - total: total, - }; - - return results; - } - async runAndRecord(params, onProgress) { const measuredValues = { tests: {}, diff --git a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs index 0ef290389..3398729f4 100644 --- a/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs +++ b/suites/todomvc/vanilla-examples/javascript-web-components/dist/src/speedometer-utils/benchmark.mjs @@ -21,9 +21,9 @@ export class BenchmarkStep { } export class AsyncBenchmarkStep extends BenchmarkStep { - async runAndRecord(params, suite, test, callback) { - const testRunner = new AsyncStepRunner(null, null, params, suite, test, callback); - const result = await testRunner.runTest(); + async runAndRecordStep(params, suite, step) { + const stepRunner = new AsyncStepRunner(null, null, params, suite, step); + const result = await stepRunner.runStep(); return result; } } @@ -59,8 +59,9 @@ export class BenchmarkSuite { performance.mark(suiteStartLabel); for (const step of this.steps) { -<<<<<<< HEAD - const { syncTime, asyncTime } = await step.runAndRecordStep(params, this, step); + const rawResult = await step.runAndRecordStep(params, this, step); + console.assert(rawResult, "Missing test return value", step); + const { syncTime, asyncTime } = rawResult; const total = syncTime + asyncTime; const result = { tests: { Sync: syncTime, Async: asyncTime }, @@ -70,12 +71,6 @@ export class BenchmarkSuite { measuredValues.tests[step.name] = result; measuredValues.total += total; } -======= - const result = await step.runAndRecordStep(params, this, step, this.record); - console.assert(result, "Missing test return value", step); - measuredValues.tests[step.name] = result; - measuredValues.total += result.total; ->>>>>>> main onProgress?.(step.name); }