Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 13 additions & 10 deletions JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ globalThis.testWorstCaseCountMap ??= new Map();
globalThis.dumpJSONResults ??= false;
globalThis.testList ??= undefined;
globalThis.startDelay ??= undefined;

let shouldReport = false;
globalThis.shouldReport ??= false;

function getIntParam(urlParams, key) {
if (!urlParams.has(key))
return undefined
const rawValue = urlParams.get(key);
const value = parseInt(rawValue);
if (value <= 0)
throw new Error(`Expected positive value for ${key}, but got ${rawValue}`)
return value
throw new Error(`Expected positive value for ${key}, but got ${rawValue}`);
return value;
}

function getTestListParam(urlParams, key) {
Expand All @@ -60,16 +59,20 @@ function getTestListParam(urlParams, key) {

if (typeof(URLSearchParams) !== "undefined") {
const urlParameters = new URLSearchParams(window.location.search);
shouldReport = urlParameters.has('report') && urlParameters.get('report').toLowerCase() == 'true';
globalThis.startDelay = getIntParam(urlParameters, "startDelay");
if (shouldReport && !globalThis.startDelay)
if (urlParameters.has("report"))
globalThis.shouldReport = urlParameters.get("report").toLowerCase() == "true";
if (urlParameters.has("startDelay"))
globalThis.startDelay = getIntParam(urlParameters, "startDelay");
if (globalThis.shouldReport && !globalThis.startDelay)
globalThis.startDelay = 4000;
if (urlParameters.has("tag"))
globalThis.testList = getTestListParam(urlParameters, "tag");
if (urlParameters.has("test"))
globalThis.testList = getTestListParam(urlParameters, "test");
globalThis.testIterationCount = getIntParam(urlParameters, "iterationCount");
globalThis.testWorstCaseCount = getIntParam(urlParameters, "worstCaseCount");
if (urlParameters.has("iterationCount"))
globalThis.testIterationCount = getIntParam(urlParameters, "iterationCount");
if (urlParameters.has("worstCaseCount"))
globalThis.testWorstCaseCount = getIntParam(urlParameters, "worstCaseCount");
}

// Used for the promise representing the current benchmark run.
Expand Down Expand Up @@ -598,7 +601,7 @@ class Driver {
if (!isInBrowser)
return;

if (!shouldReport)
if (!globalThis.shouldReport)
return;

const content = this.resultsJSON();
Expand Down
63 changes: 61 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,41 @@
*/

load("./shell-config.js")
load("./JetStreamDriver.js");

const cliFlags = { __proto__: null };
const cliArgs = [];
if (globalThis.arguments?.length) {
for (const argument of globalThis.arguments)
if (argument.startsWith("--")) {
const parts = argument.split("=");
cliFlags[parts[0].toLowerCase()] = parts.slice(1).join("=");
Comment thread
camillobruni marked this conversation as resolved.
} else
cliArgs.push(argument);
}

function getIntFlag(flags, flag) {
if (!(flag in flags))
return undefined;
const rawValue = flags[flag];
const value = parseInt(rawValue);
if (value <= 0)
throw new Error(`Expected positive value for ${flag}, but got ${rawValue}`);
return value;
}

if ("--iteration-count" in cliFlags)
globalThis.testIterationCount = getIntFlag(cliFlags, "--iteration-count");
Comment thread
camillobruni marked this conversation as resolved.
if ("--worst-case-count" in cliFlags)
Comment thread
camillobruni marked this conversation as resolved.
globalThis.testWorstCaseCount = getIntFlag(cliFlags, "--worst-case-count");
if ("--dump-json-results" in cliFlags)
globalThis.dumpJSONResults = true;
Comment thread
camillobruni marked this conversation as resolved.
if (typeof runMode !== "undefined" && runMode == "RAMification")
globalThis.RAMification = true;
Comment thread
camillobruni marked this conversation as resolved.
if ("--ramification" in cliFlags)
Comment thread
camillobruni marked this conversation as resolved.
globalThis.RAMification = true;
if (cliArgs.length)
globalThis.testList = cliArgs;


async function runJetStream() {
try {
Expand All @@ -36,4 +70,29 @@ async function runJetStream() {
throw e;
}
}
runJetStream();

load("./JetStreamDriver.js");

if ("--help" in cliFlags) {
console.log("JetStream Driver Help");
console.log("");

console.log("Options:");
console.log(" --iteration-count: Set the default iteration count.");
console.log(" --worst-case-count: Set the default worst-case count");
console.log(" --dump-json-results: Print summary json to the console.");
console.log("");

console.log("Available tags:");
const tagNames = Array.from(benchmarksByTag.keys()).sort();
for (const tagName of tagNames)
console.log(" ", tagName);
console.log("");

console.log("Available tests:");
const benchmarkNames = BENCHMARKS.map(b => b.name).sort();
for (const benchmark of benchmarkNames)
console.log(" ", benchmark);
} else {
runJetStream();
}
5 changes: 0 additions & 5 deletions shell-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@ if (isSpiderMonkey) {
globalThis.readFile = readRelativeToScript;
globalThis.arguments = scriptArgs;
}
if (globalThis.arguments?.length)
globalThis.testList = globalThis.arguments.slice();

if (typeof runMode !== "undefined" && runMode == "RAMification")
globalThis.RAMification = true;
Loading