Skip to content

Commit

Permalink
share params
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Nov 22, 2024
1 parent f7038ca commit 3310491
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 70 deletions.
2 changes: 1 addition & 1 deletion resources/benchmark-runner.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Metric } from "./metric.mjs";
import { params } from "./params.mjs";
import { params } from "./shared/params.mjs";
import { SUITE_RUNNER_LOOKUP } from "./suite-runner.mjs";

const performance = globalThis.performance;
Expand Down
2 changes: 1 addition & 1 deletion resources/developer-mode.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Suites, Tags } from "./tests.mjs";
import { params, defaultParams } from "./params.mjs";
import { params, defaultParams } from "./shared/params.mjs";

export function createDeveloperModeContainer() {
const container = document.createElement("div");
Expand Down
2 changes: 1 addition & 1 deletion resources/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BenchmarkRunner } from "./benchmark-runner.mjs";
import * as Statistics from "./statistics.mjs";
import { Suites } from "./tests.mjs";
import { renderMetricView } from "./metric-ui.mjs";
import { params } from "./params.mjs";
import { params } from "./shared/params.mjs";
import { createDeveloperModeContainer } from "./developer-mode.mjs";

// FIXME(camillobruni): Add base class
Expand Down
2 changes: 1 addition & 1 deletion resources/newssite/news-next/dist/404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/pages/_error-54de1933a164a1ff.js" defer=""></script><script src="./_next/static/oX32Acy_uXcHvOTtnzzHr/_buildManifest.js" defer=""></script><script src="./_next/static/oX32Acy_uXcHvOTtnzzHr/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"oX32Acy_uXcHvOTtnzzHr","assetPrefix":".","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-8034288b08d477a4.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/pages/_error-54de1933a164a1ff.js" defer=""></script><script src="./_next/static/AgccoHoSOfS81u54Hh8os/_buildManifest.js" defer=""></script><script src="./_next/static/AgccoHoSOfS81u54Hh8os/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"AgccoHoSOfS81u54Hh8os","assetPrefix":".","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

2 changes: 1 addition & 1 deletion resources/newssite/news-next/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><link rel="preload" href="./_next/static/css/2cf5163b53bb0adb.css" as="style"/><link rel="stylesheet" href="./_next/static/css/2cf5163b53bb0adb.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-e50e9853db18b759.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/743-fd706aeabb7828e3.js" defer=""></script><script src="./_next/static/chunks/pages/index-26ad259328ad4259.js" defer=""></script><script src="./_next/static/oX32Acy_uXcHvOTtnzzHr/_buildManifest.js" defer=""></script><script src="./_next/static/oX32Acy_uXcHvOTtnzzHr/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"oX32Acy_uXcHvOTtnzzHr","assetPrefix":".","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="./_next/static/css/a0dca1379a01e5cf.css" as="style"/><link rel="stylesheet" href="./_next/static/css/a0dca1379a01e5cf.css" data-n-g=""/><link rel="preload" href="./_next/static/css/2cf5163b53bb0adb.css" as="style"/><link rel="stylesheet" href="./_next/static/css/2cf5163b53bb0adb.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="./_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="./_next/static/chunks/webpack-8034288b08d477a4.js" defer=""></script><script src="./_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="./_next/static/chunks/main-2ba37e62325cc71b.js" defer=""></script><script src="./_next/static/chunks/pages/_app-77983e68be50f72a.js" defer=""></script><script src="./_next/static/chunks/743-fd706aeabb7828e3.js" defer=""></script><script src="./_next/static/chunks/pages/index-7a66a209e1774f2b.js" defer=""></script><script src="./_next/static/AgccoHoSOfS81u54Hh8os/_buildManifest.js" defer=""></script><script src="./_next/static/AgccoHoSOfS81u54Hh8os/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><div id="settings-container"></div><div id="notifications-container"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"AgccoHoSOfS81u54Hh8os","assetPrefix":".","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
7 changes: 6 additions & 1 deletion resources/params.mjs → resources/shared/params.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,14 @@ class Params {
return shuffleSeed;
}

toSearchParams() {
toSearchParams(forRemote = false) {
const rawParams = { ...this };
rawParams["viewport"] = `${this.viewport.width}x${this.viewport.height}`;

if (forRemote) {
delete rawParams["suites"];
delete rawParams["tags"];
}
return new URLSearchParams(rawParams).toString();
}
}
Expand Down
61 changes: 1 addition & 60 deletions resources/shared/workload-testing-utils.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
Note: This will eventually come from a separate package and should be minified.
*/

import { TestRunner } from "./test-runner.mjs";

/**
Expand Down Expand Up @@ -119,61 +115,6 @@ export function forceLayout() {
return e;
}

/** **********************************************************************
* Params
*
* All params are now forwarded from the benchmark to the workload, via its url.
* To ensure we're handling any used params the same way as the benchmark,
* we are converting the values to their native type.
*************************************************************************/
function isBoolean(value) {
if (value === "true" || value === "false")
return true;

return false;
}

function isNumber(value) {
const number = Number(value);
return Number.isInteger(number);
}

function convertToBoolean(value) {
if (value === "true")
return true;

if (value === "false")
return false;

return value;
}

function convertToNumber(value) {
return Number(value);
}

function getConvertedValue(value) {
if (isBoolean(value))
return convertToBoolean(value);

if (isNumber(value))
return convertToNumber(value);

return value;
}

function getParams(value) {
const params = Object.create(null);
const searchParams = new URLSearchParams(value);

for (const entry of searchParams.entries()) {
const [key, value] = entry;
params[key] = getConvertedValue(value);
}

return Object.freeze(params);
}

/** **********************************************************************
* Benchmark Connector
*
Expand All @@ -199,7 +140,7 @@ export function connectToBenchmark(benchmarkSuitesManager, name, version) {
switch (event.data.type) {
case "benchmark-suite":
// eslint-disable-next-line no-case-declarations
const params = getParams(window.location.search);
const { params } = await import("./params.mjs");
// eslint-disable-next-line no-case-declarations
const { result } = await benchmarkSuitesManager.getSuiteByName(event.data.name).runAndRecord(params, (test) => sendMessage({ type: "step-complete", status: "success", appId, name, test }));
sendMessage({ type: "suite-complete", status: "success", appId, result });
Expand Down
2 changes: 1 addition & 1 deletion resources/suite-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class SuiteRunner {
const frame = this.#frame;
frame.onload = () => resolve();
frame.onerror = () => reject();
frame.src = `${this.#suite.url}?${this.#params.toSearchParams()}`;
frame.src = `${this.#suite.url}?${this.#params.toSearchParams(true)}`;
});
}

Expand Down

0 comments on commit 3310491

Please sign in to comment.