@@ -271,9 +271,11 @@ function saveJsonResults(filePath, data) {
271271/**
272272 * Run a single benchmark iteration
273273 * @param {Object } results - Results object to store benchmark data
274+ * @param {(name: string) => boolean } nameFilter - Name filter
275+ * @param {number } iterations - Loop iterations per JS benchmark
274276 * @returns {Promise<void> }
275277 */
276- async function singleRun ( results , nameFilter ) {
278+ async function singleRun ( results , nameFilter , iterations ) {
277279 const options = await defaultNodeSetup ( { } )
278280 const benchmarkRunner = ( name , body ) => {
279281 if ( nameFilter && ! nameFilter ( name ) ) {
@@ -304,7 +306,6 @@ async function singleRun(results, nameFilter) {
304306 exports . run ( ) ;
305307
306308 const enumRoundtrip = new exports . EnumRoundtrip ( ) ;
307- const iterations = globalThis . __benchIterations ?? 100_000 ;
308309 benchmarkRunner ( "EnumRoundtrip/takeEnum success" , ( ) => {
309310 for ( let i = 0 ; i < iterations ; i ++ ) {
310311 enumRoundtrip . take ( { tag : APIResult . Tag . Success , param0 : "Hello, world" } )
@@ -645,9 +646,10 @@ async function singleRun(results, nameFilter) {
645646 * Run until the coefficient of variation of measurements is below the threshold
646647 * @param {Object } results - Benchmark results object
647648 * @param {Object } options - Adaptive sampling options
649+ * @param {number } iterations - Loop iterations per JS benchmark
648650 * @returns {Promise<void> }
649651 */
650- async function runUntilStable ( results , options , width , nameFilter , filterArg ) {
652+ async function runUntilStable ( results , options , width , nameFilter , filterArg , iterations ) {
651653 const {
652654 minRuns = 5 ,
653655 maxRuns = 50 ,
@@ -666,7 +668,7 @@ async function runUntilStable(results, options, width, nameFilter, filterArg) {
666668 // Update progress with estimated completion
667669 updateProgress ( runs , maxRuns , "Benchmark Progress:" , width ) ;
668670
669- await singleRun ( results , nameFilter ) ;
671+ await singleRun ( results , nameFilter , iterations ) ;
670672 runs ++ ;
671673
672674 if ( runs === 1 && Object . keys ( results ) . length === 0 ) {
@@ -772,7 +774,6 @@ async function main() {
772774 console . error ( 'Invalid --iterations value:' , args . values . iterations ) ;
773775 process . exit ( 1 ) ;
774776 }
775- globalThis . __benchIterations = iterations ;
776777
777778 if ( args . values . adaptive ) {
778779 // Adaptive sampling mode
@@ -787,7 +788,7 @@ async function main() {
787788 console . log ( `Results will be saved to: ${ args . values . output } ` ) ;
788789 }
789790
790- await runUntilStable ( results , options , width , nameFilter , filterArg ) ;
791+ await runUntilStable ( results , options , width , nameFilter , filterArg , iterations ) ;
791792 } else {
792793 // Fixed number of runs mode
793794 const runs = parseInt ( args . values . runs , 10 ) ;
@@ -809,7 +810,7 @@ async function main() {
809810 console . log ( "\nOverall Progress:" ) ;
810811 for ( let i = 0 ; i < runs ; i ++ ) {
811812 updateProgress ( i , runs , "Benchmark Runs:" , width ) ;
812- await singleRun ( results , nameFilter ) ;
813+ await singleRun ( results , nameFilter , iterations ) ;
813814 if ( i === 0 && Object . keys ( results ) . length === 0 ) {
814815 process . stdout . write ( "\n" ) ;
815816 console . error ( `No benchmarks matched filter: ${ filterArg } ` ) ;
0 commit comments