@@ -650,9 +650,6 @@ class Benchmark {
650
650
let benchmarkName = "${ this . name } ";
651
651
652
652
for (let i = 0; i < ${ this . iterations } ; i++) {
653
- if (__benchmark.prepareForNextIteration)
654
- __benchmark.prepareForNextIteration();
655
-
656
653
${ this . preIterationCode }
657
654
658
655
const iterationMarkLabel = benchmarkName + "-iteration-" + i;
@@ -668,8 +665,7 @@ class Benchmark {
668
665
669
666
results.push(Math.max(1, end - start));
670
667
}
671
- if (__benchmark.validate)
672
- __benchmark.validate(${ this . iterations } );
668
+ __benchmark.validate?.(${ this . iterations } );
673
669
top.currentResolve(results);` ;
674
670
}
675
671
@@ -684,7 +680,7 @@ class Benchmark {
684
680
get prerunCode ( ) { return null ; }
685
681
686
682
get preIterationCode ( ) {
687
- let code = "" ;
683
+ let code = `__benchmark.prepareForNextIteration?.();` ;
688
684
if ( this . plan . deterministicRandom )
689
685
code += `Math.random.__resetSeed();` ;
690
686
@@ -1185,8 +1181,7 @@ class AsyncBenchmark extends DefaultBenchmark {
1185
1181
return `
1186
1182
async function doRun() {
1187
1183
let __benchmark = new Benchmark();
1188
- if (__benchmark.init)
1189
- await __benchmark.init();
1184
+ await __benchmark.init?.();
1190
1185
let results = [];
1191
1186
let benchmarkName = "${ this . name } ";
1192
1187
@@ -1206,8 +1201,7 @@ class AsyncBenchmark extends DefaultBenchmark {
1206
1201
1207
1202
results.push(Math.max(1, end - start));
1208
1203
}
1209
- if (__benchmark.validate)
1210
- __benchmark.validate(${ this . iterations } );
1204
+ __benchmark.validate?.(${ this . iterations } );
1211
1205
top.currentResolve(results);
1212
1206
}
1213
1207
doRun().catch((error) => { top.currentReject(error); });`
0 commit comments