@@ -650,9 +650,6 @@ class Benchmark {
650650 let benchmarkName = "${ this . name } ";
651651
652652 for (let i = 0; i < ${ this . iterations } ; i++) {
653- if (__benchmark.prepareForNextIteration)
654- __benchmark.prepareForNextIteration();
655-
656653 ${ this . preIterationCode }
657654
658655 const iterationMarkLabel = benchmarkName + "-iteration-" + i;
@@ -668,8 +665,7 @@ class Benchmark {
668665
669666 results.push(Math.max(1, end - start));
670667 }
671- if (__benchmark.validate)
672- __benchmark.validate(${ this . iterations } );
668+ __benchmark.validate?.(${ this . iterations } );
673669 top.currentResolve(results);` ;
674670 }
675671
@@ -684,7 +680,7 @@ class Benchmark {
684680 get prerunCode ( ) { return null ; }
685681
686682 get preIterationCode ( ) {
687- let code = "" ;
683+ let code = `__benchmark.prepareForNextIteration?.();` ;
688684 if ( this . plan . deterministicRandom )
689685 code += `Math.random.__resetSeed();` ;
690686
@@ -1185,8 +1181,7 @@ class AsyncBenchmark extends DefaultBenchmark {
11851181 return `
11861182 async function doRun() {
11871183 let __benchmark = new Benchmark();
1188- if (__benchmark.init)
1189- await __benchmark.init();
1184+ await __benchmark.init?.();
11901185 let results = [];
11911186 let benchmarkName = "${ this . name } ";
11921187
@@ -1206,8 +1201,7 @@ class AsyncBenchmark extends DefaultBenchmark {
12061201
12071202 results.push(Math.max(1, end - start));
12081203 }
1209- if (__benchmark.validate)
1210- __benchmark.validate(${ this . iterations } );
1204+ __benchmark.validate?.(${ this . iterations } );
12111205 top.currentResolve(results);
12121206 }
12131207 doRun().catch((error) => { top.currentReject(error); });`
0 commit comments