Skip to content

Commit

Permalink
add developer menu option for async type
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Jan 7, 2025
1 parent 05ce8bf commit 930472c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/benchmark-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ export class BenchmarkRunner {
async runSuite(suite) {
// FIXME: Encapsulate more state in the SuiteRunner.
// FIXME: Return and use measured values from SuiteRunner.
const suiteRunnerClass = SUITE_RUNNER_LOOKUP[suite.type ?? "default"];
const type = suite.type ?? (params.useAsyncSteps && "async" || "default");
const suiteRunnerClass = SUITE_RUNNER_LOOKUP[type];
const suiteRunner = new suiteRunnerClass(this._frame, this._page, params, suite, this._client, this._measuredValues);
await suiteRunner.run();
}
Expand Down
9 changes: 8 additions & 1 deletion resources/developer-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function createDeveloperModeContainer() {
settings.append(createUIForWarmupSuite());
settings.append(createUIForWarmupBeforeSync());
settings.append(createUIForSyncStepDelay());
settings.append(createUIForAsyncSteps());

content.append(document.createElement("hr"));
content.append(settings);
Expand All @@ -45,6 +46,12 @@ function createUIForWarmupSuite() {
});
}

function createUIForAsyncSteps() {
return createCheckboxUI("Use Async Steps", params.useAsyncSteps, (isChecked) => {
params.useAsyncSteps = isChecked;
});
}

function createCheckboxUI(labelValue, initialValue, paramsUpdateCallback) {
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
Expand Down Expand Up @@ -255,7 +262,7 @@ function updateURL() {
}
}

const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"];
const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps"];
for (const paramKey of defaultParamKeys) {
if (params[paramKey] !== defaultParams[paramKey])
url.searchParams.set(paramKey, params[paramKey]);
Expand Down
4 changes: 4 additions & 0 deletions resources/shared/params.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class Params {
tags = [];
// Toggle running a dummy suite once before the normal test suites.
useWarmupSuite = false;
// toggle async type vs default raf type.
useAsyncSteps = false;
// Change how a test measurement is triggered and async time is measured:
// "timer": The classic (as in Speedometer 2.x) way using setTimeout
// "raf": Using rAF callbacks, both for triggering the sync part and for measuring async time.
Expand Down Expand Up @@ -50,12 +52,14 @@ export class Params {
this.tags = this._parseTags(searchParams);
this.developerMode = this._parseBooleanParam(searchParams, "developerMode");
this.useWarmupSuite = this._parseBooleanParam(searchParams, "useWarmupSuite");
this.useAsyncSteps = this._parseBooleanParam(searchParams, "useAsyncSteps");
this.waitBeforeSync = this._parseIntParam(searchParams, "waitBeforeSync", 0);
this.warmupBeforeSync = this._parseIntParam(searchParams, "warmupBeforeSync", 0);
this.measurementMethod = this._parseMeasurementMethod(searchParams);
this.shuffleSeed = this._parseShuffleSeed(searchParams);

const unused = Array.from(searchParams.keys());
console.log("unused", unused);
if (unused.length > 0)
console.error("Got unused search params", unused);
}
Expand Down

0 comments on commit 930472c

Please sign in to comment.