Skip to content

Add complexity param #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1cf416e
adding complexity param
camillobruni Oct 9, 2024
0c93e72
formatting
camillobruni Oct 9, 2024
e8aed33
use defaultNumberOfItemsToAdd
camillobruni Oct 9, 2024
c23bafc
revert non-essential changes
camillobruni Oct 9, 2024
b492131
chagne default count from steps names
camillobruni Oct 11, 2024
2204f9c
show diverging non-default params table
camillobruni Oct 11, 2024
d55137b
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Oct 11, 2024
bfb09a0
update
camillobruni Oct 11, 2024
1566f85
Merge remote-tracking branch 'webkit/main' into 2024-10-09_complexity…
camillobruni Oct 23, 2024
9ac9bf7
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Dec 10, 2024
4b78b68
cleanup
camillobruni Dec 10, 2024
bc8d4f8
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Jan 6, 2025
fe73c4e
cleanup and fix
camillobruni Jan 6, 2025
8cc92b3
fix
camillobruni Jan 6, 2025
0dcf6d9
use numberOfItemsToAdd var
camillobruni Jan 7, 2025
62ed2bc
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Jan 9, 2025
ea7d49e
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Jan 9, 2025
9973649
update news-next
camillobruni Jan 9, 2025
3cbaffb
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni May 21, 2025
92cce79
revert
camillobruni May 21, 2025
6cb8172
fix
camillobruni May 21, 2025
40741c6
fix dev-ui
camillobruni May 21, 2025
b13261b
fix
camillobruni May 21, 2025
f06cf5f
cleanup
camillobruni May 21, 2025
dc89582
rebuild news-next
camillobruni May 21, 2025
1c441cf
adding new files
camillobruni May 21, 2025
56be61a
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni May 27, 2025
51b63df
address comments
camillobruni May 27, 2025
58dd229
formatting
camillobruni May 27, 2025
047ec14
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Jun 3, 2025
52d1154
address comment
camillobruni Jun 3, 2025
ff63e88
Merge branch 'main' of github.com:camillobruni/Speedometer into 2024-…
camillobruni Jul 1, 2025
0f9314a
update
camillobruni Jul 1, 2025
429554f
updating
camillobruni Jul 1, 2025
824b21a
update
camillobruni Jul 1, 2025
57b131b
fix unused param
camillobruni Jul 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions resources/developer-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function createDeveloperModeContainer() {
settings.append(createUIForWarmupSuite());
settings.append(createUIForWarmupBeforeSync());
settings.append(createUIForSyncStepDelay());
settings.append(createUIForComplexity());

content.append(document.createElement("hr"));
content.append(settings);
Expand Down Expand Up @@ -101,11 +102,21 @@ function createUIForSyncStepDelay() {
return label;
}

function createTimeRangeUI(labelText, initialValue, unit = "ms", min = 0, max = 1000) {
function createUIForComplexity() {
const { range, label } = createTimeRangeUI("Relative complexity", params.complexity, "x", 0, 10, 0.01);
range.onchange = () => {
params.complexity = Number(range.value);
updateURL();
};
return label;
}

function createTimeRangeUI(labelText, initialValue, unit = "ms", min = 0, max = 1000, step = 1) {
const range = document.createElement("input");
range.type = "range";
range.min = min;
range.max = max;
range.step = step;
range.value = initialValue;

const rangeValueAndUnit = document.createElement("span");
Expand Down Expand Up @@ -268,7 +279,7 @@ function updateURL() {
}
}

if (params.measurementMethod !== "raf")
if (params.measurementMethod !== defaultParams.measurementMethod)
url.searchParams.set("measurementMethod", "timer");
else
url.searchParams.delete("measurementMethod");
Expand All @@ -281,6 +292,11 @@ function updateURL() {
url.searchParams.delete(paramKey);
}

if (params.complexity !== defaultParams.complexity)
url.searchParams.set("complexity", params.complexity);
else
url.searchParams.delete("complexity");

// Only push state if changed
url.search = decodeURIComponent(url.search);
if (url.href !== window.location.href)
Expand Down
6 changes: 3 additions & 3 deletions resources/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class MainBenchmarkClient {
this._showSection(window.location.hash);
}

start() {
if (this._startBenchmark())
async start() {
if (await this._startBenchmark())
this._showSection("#running");
}

_startBenchmark() {
async _startBenchmark() {
if (this._isRunning)
return false;

Expand Down
20 changes: 19 additions & 1 deletion resources/params.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Params {
// "generate": generate a random seed
// <integer>: use the provided integer as a seed
shuffleSeed = "off";
// Param to tweak the relative complexity of all suites.
// The default is 1.0, and for suites supporting this param, the duration
// roughly scales wit the complexity.
complexity = 1.0;

constructor(searchParams = undefined) {
if (searchParams)
Expand All @@ -35,8 +39,15 @@ class Params {
}
}

_parseInt(value, errorMessage) {
_parseNumber(value, errorMessage) {
const number = Number(value);
if (!Number.isFinite(number) && errorMessage)
throw new Error(`Invalid ${errorMessage} param: '${value}', expected Number.`);
return number;
}

_parseInt(value, errorMessage) {
const number = this._parseNumber(value);
if (!Number.isInteger(number) && errorMessage)
throw new Error(`Invalid ${errorMessage} param: '${value}', expected int.`);
return parseInt(number);
Expand Down Expand Up @@ -122,6 +133,13 @@ class Params {
searchParams.delete("shuffleSeed");
}

if (searchParams.has("complexity")) {
this.complexity = this._parseNumber(searchParams.get("complexity"));
if (this.complexity <= 0)
throw new Error(`Invalid complexity value: ${this.complexity}, must be > 0.0`);
searchParams.delete("complexity");
}

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