Skip to content

Commit b304e4f

Browse files
committed
chore: apply numeric separator formatting to codebase
Auto-fixed by numeric-separators-style rule to improve readability of large numeric literals (e.g., 1000000 → 1_000_000).
1 parent 7ea6e16 commit b304e4f

37 files changed

+212
-210
lines changed

examples/bench/performance-tips.bench.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
benchmarks: {
3030
// Fast operations need more iterations
3131
'Array Access': {
32-
config: { iterations: 10000 },
32+
config: { iterations: 10_000 },
3333
fn: () => iterationState.smallArray[50],
3434
tags: ['fast', 'array'],
3535
},
@@ -46,7 +46,7 @@ export default {
4646
iterationState.smallArray = Array.from({ length: 100 }, (_, i) => i);
4747
iterationState.largeComputation = () => {
4848
let result = 0;
49-
for (let i = 0; i < 100000; i++) {
49+
for (let i = 0; i < 100_000; i++) {
5050
result += Math.sqrt(i);
5151
}
5252
return result;
@@ -84,7 +84,7 @@ export default {
8484

8585
setup: () => {
8686
// Generate large dataset once for all benchmarks
87-
optimizationState.dataset = Array.from({ length: 10000 }, (_, i) => ({
87+
optimizationState.dataset = Array.from({ length: 10_000 }, (_, i) => ({
8888
id: i,
8989
name: `item-${i}`,
9090
value: Math.random(),

examples/profiling-demo.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// Medium function - string manipulation
1111
const parseAndFormat = () => {
12-
const data = Array.from({ length: 100000 }, (_, i) => {
12+
const data = Array.from({ length: 100_000 }, (_, i) => {
1313
const raw = `${i}|item-${i}|${Math.random() * 100}`;
1414
const parts = raw.split('|');
1515
return {
@@ -23,7 +23,7 @@ const parseAndFormat = () => {
2323

2424
// Warm function - moderate CPU time
2525
const processStrings = () => {
26-
const strings = Array.from({ length: 500000 }, (_, i) => `item-${i}`);
26+
const strings = Array.from({ length: 500_000 }, (_, i) => `item-${i}`);
2727
return strings
2828
.map((s) => s.toUpperCase())
2929
.filter((s) => s.includes('5'))
@@ -32,7 +32,7 @@ const processStrings = () => {
3232

3333
// Medium-warm function - JSON serialization
3434
const serializeData = () => {
35-
const data = Array.from({ length: 50000 }, (_, i) => ({
35+
const data = Array.from({ length: 50_000 }, (_, i) => ({
3636
id: i,
3737
metadata: { created: Date.now(), updated: Date.now() },
3838
name: `Record ${i}`,
@@ -48,13 +48,13 @@ const simpleCalculation = () => {
4848

4949
// Hot function - lots of CPU time
5050
const sortLargeArray = () => {
51-
const arr = Array.from({ length: 1000000 }, () => Math.random());
51+
const arr = Array.from({ length: 1_000_000 }, () => Math.random());
5252
return arr.sort((a, b) => a - b);
5353
};
5454

5555
// Warm function - object manipulation
5656
const transformData = () => {
57-
const data = Array.from({ length: 200000 }, (_, i) => ({
57+
const data = Array.from({ length: 200_000 }, (_, i) => ({
5858
id: i,
5959
name: `Item ${i}`,
6060
value: Math.random() * 100,
@@ -72,7 +72,7 @@ const transformData = () => {
7272
// Another hot function - regex processing
7373
const validateEmails = () => {
7474
const emails = Array.from(
75-
{ length: 100000 },
75+
{ length: 100_000 },
7676
(_, i) => `user${i}@example.com`,
7777
);
7878
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
@@ -111,7 +111,7 @@ validateEmails();
111111
transformData();
112112

113113
console.log('Simple calculations (cold path)...');
114-
for (let i = 0; i < 10000; i++) {
114+
for (let i = 0; i < 10_000; i++) {
115115
simpleCalculation();
116116
}
117117

src/cli/commands/baseline.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ const formatDuration = (nanoseconds: number): string => {
6969
if (nanoseconds < 1000) {
7070
return `${nanoseconds.toFixed(2)}ns`;
7171
}
72-
if (nanoseconds < 1000000) {
72+
if (nanoseconds < 1_000_000) {
7373
return `${(nanoseconds / 1000).toFixed(2)}μs`;
7474
}
75-
if (nanoseconds < 1000000000) {
76-
return `${(nanoseconds / 1000000).toFixed(2)}ms`;
75+
if (nanoseconds < 1_000_000_000) {
76+
return `${(nanoseconds / 1_000_000).toFixed(2)}ms`;
7777
}
78-
return `${(nanoseconds / 1000000000).toFixed(2)}s`;
78+
return `${(nanoseconds / 1_000_000_000).toFixed(2)}s`;
7979
};
8080

8181
/**
@@ -85,13 +85,13 @@ const formatOpsPerSec = (ops: number): string => {
8585
if (ops < 1000) {
8686
return `${ops.toFixed(2)} ops/sec`;
8787
}
88-
if (ops < 1000000) {
88+
if (ops < 1_000_000) {
8989
return `${(ops / 1000).toFixed(2)}K ops/sec`;
9090
}
91-
if (ops < 1000000000) {
92-
return `${(ops / 1000000).toFixed(2)}M ops/sec`;
91+
if (ops < 1_000_000_000) {
92+
return `${(ops / 1_000_000).toFixed(2)}M ops/sec`;
9393
}
94-
return `${(ops / 1000000000).toFixed(2)}B ops/sec`;
94+
return `${(ops / 1_000_000_000).toFixed(2)}B ops/sec`;
9595
};
9696

9797
/**

src/cli/commands/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const PROJECT_TEMPLATES = {
5151
outputDir: DEFAULT_OUTPUT_DIR,
5252
pattern: `${DEFAULT_BENCHMARK_DIR}/**/*.bench.{js,ts}`,
5353
reporters: ['human', 'json'],
54-
time: 10000,
54+
time: 10_000,
5555
warmup: 50,
5656
},
5757
description: 'Feature-rich setup with multiple reporters and configuration',
@@ -77,7 +77,7 @@ const PROJECT_TEMPLATES = {
7777
outputDir: DEFAULT_OUTPUT_DIR,
7878
pattern: `${DEFAULT_BENCHMARK_DIR}/**/*.bench.{js,ts}`,
7979
reporters: ['human', 'json'],
80-
time: 15000,
80+
time: 15_000,
8181
warmup: 100,
8282
},
8383
description: 'Optimized for library performance testing',

src/cli/commands/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const getDefaultTestConfig = (
5555
tags: [],
5656
thresholds: {},
5757
time: 1000,
58-
timeout: 30000,
58+
timeout: 30_000,
5959
verbose,
6060
warmup,
6161
});

src/config/budget-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const parseTimeString = (value: string): number => {
2626
ms: 1_000_000,
2727
ns: 1,
2828
s: 1_000_000_000,
29-
us: 1_000,
29+
us: 1000,
3030
};
3131

3232
return num * multipliers[unit as keyof typeof multipliers];

src/core/engines/accurate-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class AccurateEngine extends ModestBenchEngine {
3838
* Maximum iterations per round to prevent overwhelming Node.js test runner
3939
* and excessive memory usage
4040
*/
41-
private static readonly MAX_ITERATIONS_PER_ROUND = 10000;
41+
private static readonly MAX_ITERATIONS_PER_ROUND = 10_000;
4242

4343
/**
4444
* Maximum iterations per round for async functions (much lower due to

src/formatters/history/compare.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export class HistoryCompareFormatter implements HistoryFormatter<CompareResult>
5151
lines.push('');
5252

5353
for (const comparison of data.tasksInBoth) {
54-
const mean1 = comparison.run1!.mean / 1000000; // Convert to ms
55-
const mean2 = comparison.run2!.mean / 1000000;
54+
const mean1 = comparison.run1!.mean / 1_000_000; // Convert to ms
55+
const mean2 = comparison.run2!.mean / 1_000_000;
5656
const changeSign = comparison.percentChange >= 0 ? '+' : '';
5757
const changeStr = `${changeSign}${comparison.percentChange.toFixed(1)}%`;
5858

@@ -73,8 +73,8 @@ export class HistoryCompareFormatter implements HistoryFormatter<CompareResult>
7373
);
7474

7575
// Min - highlight higher number
76-
const min1 = comparison.run1!.min / 1000000;
77-
const min2 = comparison.run2!.min / 1000000;
76+
const min1 = comparison.run1!.min / 1_000_000;
77+
const min2 = comparison.run2!.min / 1_000_000;
7878
const minHigher = min2 > min1;
7979
const min1Str = minHigher
8080
? colorize('magenta', `${min1.toFixed(3)}ms`)
@@ -87,8 +87,8 @@ export class HistoryCompareFormatter implements HistoryFormatter<CompareResult>
8787
);
8888

8989
// Max - highlight higher number
90-
const max1 = comparison.run1!.max / 1000000;
91-
const max2 = comparison.run2!.max / 1000000;
90+
const max1 = comparison.run1!.max / 1_000_000;
91+
const max2 = comparison.run2!.max / 1_000_000;
9292
const maxHigher = max2 > max1;
9393
const max1Str = maxHigher
9494
? colorize('magenta', `${max1.toFixed(3)}ms`)

src/formatters/history/show.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ const formatTime = (ns: number): string => {
148148
if (ns < 1000) {
149149
return `${ns.toFixed(2)}ns`;
150150
}
151-
if (ns < 1000000) {
151+
if (ns < 1_000_000) {
152152
return `${(ns / 1000).toFixed(3)}µs`;
153153
}
154-
return `${(ns / 1000000).toFixed(3)}ms`;
154+
return `${(ns / 1_000_000).toFixed(3)}ms`;
155155
};

src/formatters/history/trends.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const NS_PER_MS = 1_000_000;
2424
/**
2525
* Nanoseconds per microsecond conversion constant
2626
*/
27-
const NS_PER_US = 1_000;
27+
const NS_PER_US = 1000;
2828

2929
/**
3030
* Intelligently format a time range with appropriate precision Displays

0 commit comments

Comments
 (0)