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
15 changes: 14 additions & 1 deletion JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ const measureTotalTimeAsSubtest = false; // Once we move to preloading all resou
const defaultIterationCount = 120;
const defaultWorstCaseCount = 4;

if (!JetStreamParams.prefetchResources && isInBrowser)
if (!JetStreamParams.prefetchResources && isInBrowser) {
console.warn("Disabling resource prefetching! All compressed files must have been decompressed using `npm run decompress`");
}

if (JetStreamParams.forceGC && typeof globalThis.gc === "undefined") {
console.warn("Force-gc is set, but globalThis.gc() is not available.");
}

if (!isInBrowser && JetStreamParams.prefetchResources) {
// Use the wasm compiled zlib as a polyfill when decompression stream is
Expand Down Expand Up @@ -913,6 +918,14 @@ class Benchmark {
if (this.isDone)
throw new Error(`Cannot run Benchmark ${this.name} twice`);
this._state = BenchmarkState.PREPARE;

if (JetStreamParams.forceGC) {
// This will trigger for individual benchmarks in
// GroupedBenchmarks since they delegate .run() to their inner
// non-grouped benchmarks.
globalThis?.gc();
}

const scripts = isInBrowser ? new BrowserScripts(this.preloads) : new ShellScripts(this.preloads);

if (!!this.plan.deterministicRandom)
Expand Down
4 changes: 4 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const CLI_PARAMS = {
help: "Custom code to run after each iteration.",
param: "customPostIterationCode",
},
"force-gc": {
help: "Force garbage collection before each benchmark, requires engine support.",
param: "forceGC",
},
};

const cliParams = new Map();
Expand Down
2 changes: 2 additions & 0 deletions utils/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Params {
groupDetails = false

RAMification = false;
forceGC = false;
dumpJSONResults = false;
dumpTestList = false;
// Override iteration and worst-case counts per workload.
Expand Down Expand Up @@ -70,6 +71,7 @@ class Params {
this.dumpJSONResults = this._parseBooleanParam(sourceParams, "dumpJSONResults");
this.groupDetails = this._parseBooleanParam(sourceParams, "groupDetails");
this.dumpTestList = this._parseBooleanParam(sourceParams, "dumpTestList");
this.forceGC = this._parseBooleanParam(sourceParams, "forceGC");

this.customPreIterationCode = this._parseStringParam(sourceParams, "customPreIterationCode");
this.customPostIterationCode = this._parseStringParam(sourceParams, "customPostIterationCode");
Expand Down
Loading