Add --no-prefetch cli flag
--no-prefetch will directly use `load(...)` instead of
just injecting the script sources which makes it easier to navigate
and investigate profiles.
- Support more complex command line args and flags
- Add --help to cli.js
Bug: 411303884
Change-Id: Ica5aaaabf7ce9cc47862af80f5e35cc2ac4b0186
Reviewed-on: https://chromium-review.googlesource.com/c/external/github.com/WebKit/JetStream/+/6483189
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
diff --git a/JetStreamDriver.js b/JetStreamDriver.js
index 913483e..4ddc421 100644
--- a/JetStreamDriver.js
+++ b/JetStreamDriver.js
@@ -202,8 +202,11 @@
}
async _loadInternal(url) {
- if (!isInBrowser)
+ if (!isInBrowser) {
+ if (!globalThis.prefetchResources)
+ return Promise.resolve(`load("${url}");`);
return Promise.resolve(readFile(url));
+ }
let response;
let tries = 3;
diff --git a/cli.js b/cli.js
index b87d92c..2b86620 100644
--- a/cli.js
+++ b/cli.js
@@ -24,6 +24,8 @@
*/
globalThis.isInBrowser = false;
+globalThis.prefetchResources = true;
+
if (typeof console === 'undefined')
var console = {}
if (typeof console.log === 'undefined')
@@ -52,14 +54,33 @@
if (isSpiderMonkey)
globalThis.readFile = readRelativeToScript;
+
+let cliFlags = {};
+let cliArgs = [];
+
+if (typeof arguments != "undefined" && arguments.length > 0) {
+ for (const arg of arguments) {
+ if (arg.startsWith("--")) {
+ const parts = arg.split("=");
+ cliFlags[parts[0]] = parts.slice(1).join("=");
+ } else {
+ cliArgs.push(arg);
+ }
+ }
+}
+
if (typeof testList === "undefined") {
- if (typeof arguments != "undefined" && arguments.length > 0) {
- testList = arguments.slice();
+ if (cliArgs.length > 0) {
+ testList = cliArgs;
} else {
testList = undefined;
}
}
+if ("--no-prefetch" in cliFlags || "--noprefetch" in cliFlags)
+ globalThis.prefetchResources = false
+
+
if (typeof testIterationCount === "undefined")
testIterationCount = undefined;
@@ -70,6 +91,20 @@
load("./JetStreamDriver.js");
+if ("--help" in cliFlags) {
+ print("JetStream Driver Help")
+ print("")
+ print("Options:")
+ print(" --no-prefetch: directly use load('...') for benchmark resources.")
+ print("")
+ print("Available tests:")
+ for (const test of testPlans)
+ print(" ", test.name)
+} else {
+ print("Running tests: " + testList)
+ runJetStream();
+}
+
async function runJetStream() {
try {
await JetStream.initialize();
@@ -78,4 +113,3 @@
console.log("JetStream2 failed: " + e);
}
}
-runJetStream();
diff --git a/index.html b/index.html
index b364944..a598ef3 100644
--- a/index.html
+++ b/index.html
@@ -36,6 +36,8 @@
const isInBrowser = true;
const isD8 = false;
const isSpiderMonkey = false;
+ let prefetchResources = true;
+
var allIsGood = true;
window.onerror = function(e) {
if (e == "Script error.") {