diff --git a/resources/benchmark-runner.mjs b/resources/benchmark-runner.mjs index 8a4e2958b..111830bd5 100644 --- a/resources/benchmark-runner.mjs +++ b/resources/benchmark-runner.mjs @@ -116,9 +116,58 @@ class PageElement { } } +// The WarmupSuite is used to make sure all runner helper functions and +// classes are compiled, to avoid unnecessary pauses due to delayed +// compilation of runner methods in the middle of the measuring cycle. +const WarmupSuite = { + name: "Warmup", + url: "warmup/index.html", + async prepare(page) { + await page.waitForElement("#testItem"); + }, + tests: [ + // Make sure to run ever page.method once at least + new BenchmarkTestStep("WarmingUpPageMethods", (page) => { + let results = []; + results.push(page.querySelector(".testItem")); + results.push(page.querySelectorAll(".item")); + results.push(page.getElementById("testItem")); + }), + new BenchmarkTestStep("WarmingUpPageElementMethods", (page) => { + const item = page.getElementById("testItem"); + item.setValue("value"); + item.click(); + item.focus(); + item.dispatchEvent("change"); + item.enter("keypress"); + item.dispatchEvent("input"); + item.enter("keyup"); + }), + new BenchmarkTestStep("WarmingUpPageElementMouseMethods", (page) => { + const item = page.getElementById("testItem"); + const mouseEventOptions = { clientX: 100, clientY: 100, bubbles: true, cancelable: true }; + const wheelEventOptions = { + clientX: 200, + clientY: 200, + deltaMode: 0, + delta: -10, + deltaY: -10, + bubbles: true, + cancelable: true, + }; + item.dispatchEvent("mousedown", mouseEventOptions, MouseEvent); + item.dispatchEvent("mousemove", mouseEventOptions, MouseEvent); + item.dispatchEvent("mouseup", mouseEventOptions, MouseEvent); + item.dispatchEvent("wheel", wheelEventOptions, WheelEvent); + }), + ], +}; + export class BenchmarkRunner { constructor(suites, client) { this._suites = suites; + if (params.useWarmupSuite) + this._suites = [WarmupSuite, ...suites]; this._client = client; this._page = null; this._metrics = { @@ -263,6 +312,11 @@ export class BenchmarkRunner { } async _recordTestResults(suite, test, syncTime, asyncTime, unused_height, testDoneCallback) { + // Skip reporting updates for the warmup suite. + if (suite === WarmupSuite) { + testDoneCallback(); + return; + } const suiteResults = this._measuredValues.tests[suite.name] || { tests: {}, total: 0 }; const total = syncTime + asyncTime; this._measuredValues.tests[suite.name] = suiteResults; diff --git a/resources/params.mjs b/resources/params.mjs index af6c779e9..68ffb4f28 100644 --- a/resources/params.mjs +++ b/resources/params.mjs @@ -7,6 +7,7 @@ class Params { startAutomatically = false; iterationCount = 10; suites = []; + useWarmupSuite = false; constructor(searchParams = undefined) { if (searchParams) @@ -48,6 +49,11 @@ class Params { const unused = Array.from(searchParams.keys()); if (unused.length > 0) console.error("Got unused search params", unused); + + if (searchParams.has("useWarmupSuite")) { + this.useWarmupSuite = true; + searchParams.delete("useWarmupSuite"); + } } toSearchParams() { diff --git a/resources/warmup/index.html b/resources/warmup/index.html new file mode 100644 index 000000000..80f84178b --- /dev/null +++ b/resources/warmup/index.html @@ -0,0 +1,18 @@ + + +
+ +