@@ -25,6 +25,7 @@ const DEFAULT_CONFIG: ModestBenchConfig = {
2525 bail : false ,
2626 exclude : [ 'node_modules/**' , '.git/**' ] ,
2727 iterations : 100 , // Sufficient iterations for reliable statistics
28+ limitBy : 'iterations' , // Default to limiting by iteration count
2829 metadata : { } ,
2930 outputDir : './benchmark-results' ,
3031 pattern : '**/*.bench.{js,ts,mjs,cjs,mts}' ,
@@ -37,7 +38,6 @@ const DEFAULT_CONFIG: ModestBenchConfig = {
3738 timeout : 30000 , // 30 seconds
3839 verbose : false ,
3940 warmup : 0 , // No warmup by default for test speed
40- limitBy : 'iterations' , // Default to limiting by iteration count
4141} ;
4242
4343/**
@@ -127,43 +127,6 @@ export class ModestBenchConfigurationManager implements ConfigurationManager {
127127 }
128128 }
129129
130- /**
131- * Apply smart defaults for limitBy based on which flags were provided
132- */
133- private applySmartDefaults (
134- merged : ModestBenchConfig ,
135- cliArgs : Record < string , unknown > ,
136- fileConfig : Partial < ModestBenchConfig > ,
137- ) : ModestBenchConfig {
138- // If limitBy was explicitly provided in CLI or file, use it
139- if ( cliArgs [ 'limit-by' ] || cliArgs . limitBy || fileConfig . limitBy ) {
140- return merged ;
141- }
142-
143- // Determine if user explicitly provided time or iterations
144- const userProvidedTime = 'time' in cliArgs || 't' in cliArgs ;
145- const userProvidedIterations =
146- 'iterations' in cliArgs || 'i' in cliArgs ;
147-
148- let smartDefault : 'time' | 'iterations' | 'any' ;
149-
150- if ( userProvidedTime && userProvidedIterations ) {
151- // Both provided → stop at whichever comes first
152- smartDefault = 'any' ;
153- } else if ( userProvidedTime ) {
154- // Only time → limit by time
155- smartDefault = 'time' ;
156- } else {
157- // Only iterations (or neither) → limit by iterations
158- smartDefault = 'iterations' ;
159- }
160-
161- return {
162- ...merged ,
163- limitBy : smartDefault ,
164- } ;
165- }
166-
167130 /**
168131 * Merge multiple configuration objects with precedence
169132 */
@@ -348,6 +311,42 @@ export class ModestBenchConfigurationManager implements ConfigurationManager {
348311 } ;
349312 }
350313
314+ /**
315+ * Apply smart defaults for limitBy based on which flags were provided
316+ */
317+ private applySmartDefaults (
318+ merged : ModestBenchConfig ,
319+ cliArgs : Record < string , unknown > ,
320+ fileConfig : Partial < ModestBenchConfig > ,
321+ ) : ModestBenchConfig {
322+ // If limitBy was explicitly provided in CLI or file, use it
323+ if ( cliArgs [ 'limit-by' ] || cliArgs . limitBy || fileConfig . limitBy ) {
324+ return merged ;
325+ }
326+
327+ // Determine if user explicitly provided time or iterations
328+ const userProvidedTime = 'time' in cliArgs || 't' in cliArgs ;
329+ const userProvidedIterations = 'iterations' in cliArgs || 'i' in cliArgs ;
330+
331+ let smartDefault : 'any' | 'iterations' | 'time' ;
332+
333+ if ( userProvidedTime && userProvidedIterations ) {
334+ // Both provided → stop at whichever comes first
335+ smartDefault = 'any' ;
336+ } else if ( userProvidedTime ) {
337+ // Only time → limit by time
338+ smartDefault = 'time' ;
339+ } else {
340+ // Only iterations (or neither) → limit by iterations
341+ smartDefault = 'iterations' ;
342+ }
343+
344+ return {
345+ ...merged ,
346+ limitBy : smartDefault ,
347+ } ;
348+ }
349+
351350 /**
352351 * Create a cosmiconfig explorer for loading configuration files
353352 */
0 commit comments