Skip to content
Merged
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
53 changes: 27 additions & 26 deletions JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,29 +725,30 @@ class Benchmark {
}

get runnerCode() {
return `
let __benchmark = new Benchmark(${this.iterations});
let results = [];
let benchmarkName = "${this.name}";
return `{
const benchmark = new Benchmark(${this.iterations});
const results = [];
const benchmarkName = "${this.name}";

for (let i = 0; i < ${this.iterations}; i++) {
${this.preIterationCode}

const iterationMarkLabel = benchmarkName + "-iteration-" + i;
const iterationStartMark = performance.mark(iterationMarkLabel);

let start = performance.now();
__benchmark.runIteration();
let end = performance.now();
const start = performance.now();
benchmark.runIteration(i);
const end = performance.now();

performance.measure(iterationMarkLabel, iterationMarkLabel);

${this.postIterationCode}

results.push(Math.max(1, end - start));
}
__benchmark.validate?.(${this.iterations});
top.currentResolve(results);`;
benchmark.validate?.(${this.iterations});
top.currentResolve(results);
};`;
}

processResults(results) {
Expand All @@ -773,7 +774,7 @@ class Benchmark {
get prerunCode() { return null; }

get preIterationCode() {
let code = `__benchmark.prepareForNextIteration?.();`;
let code = `benchmark.prepareForNextIteration?.();`;
if (this.plan.deterministicRandom)
code += `Math.random.__resetSeed();`;

Expand Down Expand Up @@ -924,7 +925,7 @@ class Benchmark {
updateCounter() {
const counter = JetStream.counter;
++counter.loadedResources;
var statusElement = document.getElementById("status");
const statusElement = document.getElementById("status");
statusElement.innerHTML = `Loading ${counter.loadedResources} of ${counter.totalResources} ...`;
}

Expand Down Expand Up @@ -1218,28 +1219,28 @@ class AsyncBenchmark extends DefaultBenchmark {
get runnerCode() {
return `
async function doRun() {
let __benchmark = new Benchmark();
await __benchmark.init?.();
let results = [];
let benchmarkName = "${this.name}";
const benchmark = new Benchmark(${this.iterations});
await benchmark.init?.();
const results = [];
const benchmarkName = "${this.name}";

for (let i = 0; i < ${this.iterations}; i++) {
${this.preIterationCode}

const iterationMarkLabel = benchmarkName + "-iteration-" + i;
const iterationStartMark = performance.mark(iterationMarkLabel);

let start = performance.now();
await __benchmark.runIteration();
let end = performance.now();
const start = performance.now();
await benchmark.runIteration(i);
const end = performance.now();

performance.measure(iterationMarkLabel, iterationMarkLabel);

${this.postIterationCode}

results.push(Math.max(1, end - start));
}
__benchmark.validate?.(${this.iterations});
benchmark.validate?.(${this.iterations});
top.currentResolve(results);
}
doRun().catch((error) => { top.currentReject(error); });`
Expand Down Expand Up @@ -1301,16 +1302,16 @@ class WSLBenchmark extends Benchmark {
}

get runnerCode() {
return `
let benchmark = new Benchmark();
return `{
const benchmark = new Benchmark();
const benchmarkName = "${this.name}";

let results = [];
const results = [];
{
const markLabel = benchmarkName + "-stdlib";
const startMark = performance.mark(markLabel);

let start = performance.now();
const start = performance.now();
benchmark.buildStdlib();
results.push(performance.now() - start);

Expand All @@ -1321,15 +1322,15 @@ class WSLBenchmark extends Benchmark {
const markLabel = benchmarkName + "-mainRun";
const startMark = performance.mark(markLabel);

let start = performance.now();
const start = performance.now();
benchmark.run();
results.push(performance.now() - start);

performance.measure(markLabel, markLabel);
}

top.currentResolve(results);
`;
}`;
}

subScores() {
Expand Down Expand Up @@ -1410,7 +1411,7 @@ class WasmLegacyBenchmark extends Benchmark {

if (isInBrowser) {
str += `
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
Expand Down
Loading