Skip to content

Commit f5813ec

Browse files
committed
chore: lint & format
1 parent 2974ba8 commit f5813ec

File tree

3 files changed

+41
-42
lines changed

3 files changed

+41
-42
lines changed

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"TKTK",
5050
"onsave",
5151
"toshimaru",
52-
"wagoid"
52+
"wagoid",
53+
"limitby"
5354
],
5455
"words": ["bupkis"]
5556
}

src/config/manager.ts

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/

test/integration/limit-by.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Integration tests for --limit-by flag
33
*
4-
* Verifies that the --limit-by flag correctly controls whether benchmarks
5-
* are limited by time, iterations, or both.
4+
* Verifies that the --limit-by flag correctly controls whether benchmarks are
5+
* limited by time, iterations, or both.
66
*/
77

88
import { expect } from 'bupkis';
@@ -340,4 +340,3 @@ export default {
340340
});
341341
});
342342
});
343-

0 commit comments

Comments
 (0)