@@ -732,29 +732,30 @@ class Benchmark {
732
732
}
733
733
734
734
get runnerCode ( ) {
735
- return `
736
- let __benchmark = new Benchmark(${ this . iterations } );
737
- let results = [];
738
- let benchmarkName = "${ this . name } ";
735
+ return `{
736
+ const benchmark = new Benchmark(${ this . iterations } );
737
+ const results = [];
738
+ const benchmarkName = "${ this . name } ";
739
739
740
740
for (let i = 0; i < ${ this . iterations } ; i++) {
741
741
${ this . preIterationCode }
742
742
743
743
const iterationMarkLabel = benchmarkName + "-iteration-" + i;
744
744
const iterationStartMark = performance.mark(iterationMarkLabel);
745
745
746
- let start = performance.now();
747
- __benchmark .runIteration();
748
- let end = performance.now();
746
+ const start = performance.now();
747
+ benchmark .runIteration(i );
748
+ const end = performance.now();
749
749
750
750
performance.measure(iterationMarkLabel, iterationMarkLabel);
751
751
752
752
${ this . postIterationCode }
753
753
754
754
results.push(Math.max(1, end - start));
755
755
}
756
- __benchmark.validate?.(${ this . iterations } );
757
- top.currentResolve(results);` ;
756
+ benchmark.validate?.(${ this . iterations } );
757
+ top.currentResolve(results);
758
+ };` ;
758
759
}
759
760
760
761
processResults ( results ) {
@@ -780,7 +781,7 @@ class Benchmark {
780
781
get prerunCode ( ) { return null ; }
781
782
782
783
get preIterationCode ( ) {
783
- let code = `__benchmark .prepareForNextIteration?.();` ;
784
+ let code = `benchmark .prepareForNextIteration?.();` ;
784
785
if ( this . plan . deterministicRandom )
785
786
code += `Math.random.__resetSeed();` ;
786
787
@@ -931,7 +932,7 @@ class Benchmark {
931
932
updateCounter ( ) {
932
933
const counter = JetStream . counter ;
933
934
++ counter . loadedResources ;
934
- var statusElement = document . getElementById ( "status" ) ;
935
+ const statusElement = document . getElementById ( "status" ) ;
935
936
statusElement . innerHTML = `Loading ${ counter . loadedResources } of ${ counter . totalResources } ...` ;
936
937
}
937
938
@@ -1225,28 +1226,28 @@ class AsyncBenchmark extends DefaultBenchmark {
1225
1226
get runnerCode ( ) {
1226
1227
return `
1227
1228
async function doRun() {
1228
- let __benchmark = new Benchmark();
1229
- await __benchmark .init?.();
1230
- let results = [];
1231
- let benchmarkName = "${ this . name } ";
1229
+ const benchmark = new Benchmark(${ this . iterations } );
1230
+ await benchmark .init?.();
1231
+ const results = [];
1232
+ const benchmarkName = "${ this . name } ";
1232
1233
1233
1234
for (let i = 0; i < ${ this . iterations } ; i++) {
1234
1235
${ this . preIterationCode }
1235
1236
1236
1237
const iterationMarkLabel = benchmarkName + "-iteration-" + i;
1237
1238
const iterationStartMark = performance.mark(iterationMarkLabel);
1238
1239
1239
- let start = performance.now();
1240
- await __benchmark .runIteration();
1241
- let end = performance.now();
1240
+ const start = performance.now();
1241
+ await benchmark .runIteration(i );
1242
+ const end = performance.now();
1242
1243
1243
1244
performance.measure(iterationMarkLabel, iterationMarkLabel);
1244
1245
1245
1246
${ this . postIterationCode }
1246
1247
1247
1248
results.push(Math.max(1, end - start));
1248
1249
}
1249
- __benchmark .validate?.(${ this . iterations } );
1250
+ benchmark .validate?.(${ this . iterations } );
1250
1251
top.currentResolve(results);
1251
1252
}
1252
1253
doRun().catch((error) => { top.currentReject(error); });`
@@ -1308,16 +1309,16 @@ class WSLBenchmark extends Benchmark {
1308
1309
}
1309
1310
1310
1311
get runnerCode ( ) {
1311
- return `
1312
- let benchmark = new Benchmark();
1312
+ return `{
1313
+ const benchmark = new Benchmark();
1313
1314
const benchmarkName = "${ this . name } ";
1314
1315
1315
- let results = [];
1316
+ const results = [];
1316
1317
{
1317
1318
const markLabel = benchmarkName + "-stdlib";
1318
1319
const startMark = performance.mark(markLabel);
1319
1320
1320
- let start = performance.now();
1321
+ const start = performance.now();
1321
1322
benchmark.buildStdlib();
1322
1323
results.push(performance.now() - start);
1323
1324
@@ -1328,15 +1329,15 @@ class WSLBenchmark extends Benchmark {
1328
1329
const markLabel = benchmarkName + "-mainRun";
1329
1330
const startMark = performance.mark(markLabel);
1330
1331
1331
- let start = performance.now();
1332
+ const start = performance.now();
1332
1333
benchmark.run();
1333
1334
results.push(performance.now() - start);
1334
1335
1335
1336
performance.measure(markLabel, markLabel);
1336
1337
}
1337
1338
1338
1339
top.currentResolve(results);
1339
- ` ;
1340
+ } ` ;
1340
1341
}
1341
1342
1342
1343
subScores ( ) {
@@ -1417,7 +1418,7 @@ class WasmLegacyBenchmark extends Benchmark {
1417
1418
1418
1419
if ( isInBrowser ) {
1419
1420
str += `
1420
- var xhr = new XMLHttpRequest();
1421
+ const xhr = new XMLHttpRequest();
1421
1422
xhr.open('GET', path, true);
1422
1423
xhr.responseType = 'arraybuffer';
1423
1424
xhr.onload = function() {
0 commit comments