modestbench 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +6 -2
- package/dist/cli/commands/run.cjs +17 -11
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.js +9 -3
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/test.cjs +14 -15
- package/dist/cli/commands/test.cjs.map +1 -1
- package/dist/cli/commands/test.d.cts.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +2 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.cjs +3 -0
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/reporters/index.cjs +3 -1
- package/dist/reporters/index.cjs.map +1 -1
- package/dist/reporters/index.d.cts +1 -0
- package/dist/reporters/index.d.cts.map +1 -1
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js +1 -0
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/nyan.cjs +318 -0
- package/dist/reporters/nyan.cjs.map +1 -0
- package/dist/reporters/nyan.d.cts +118 -0
- package/dist/reporters/nyan.d.cts.map +1 -0
- package/dist/reporters/nyan.d.ts +118 -0
- package/dist/reporters/nyan.d.ts.map +1 -0
- package/dist/reporters/nyan.js +314 -0
- package/dist/reporters/nyan.js.map +1 -0
- package/dist/types/core.cjs.map +1 -1
- package/dist/types/core.d.cts +13 -12
- package/dist/types/core.d.cts.map +1 -1
- package/dist/types/core.d.ts +13 -12
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +0 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/commands/run.ts +10 -3
- package/src/cli/commands/test.ts +2 -3
- package/src/cli/index.ts +8 -0
- package/src/constants.ts +2 -1
- package/src/index.ts +3 -0
- package/src/reporters/index.ts +1 -0
- package/src/reporters/nyan.ts +409 -0
- package/src/types/core.ts +16 -14
- package/src/types/index.ts +0 -3
- package/dist/types/cli.cjs +0 -12
- package/dist/types/cli.cjs.map +0 -1
- package/dist/types/cli.d.cts +0 -75
- package/dist/types/cli.d.cts.map +0 -1
- package/dist/types/cli.d.ts +0 -75
- package/dist/types/cli.d.ts.map +0 -1
- package/dist/types/cli.js +0 -9
- package/dist/types/cli.js.map +0 -1
- package/src/types/cli.ts +0 -82
package/src/cli/commands/test.ts
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* executing them through a lightweight benchmark runner.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { hostname } from 'node:os';
|
|
9
|
-
import { cpus, freemem, totalmem } from 'node:os';
|
|
8
|
+
import { cpus, freemem, hostname, totalmem } from 'node:os';
|
|
10
9
|
import { resolve } from 'node:path';
|
|
11
10
|
import { performance } from 'node:perf_hooks';
|
|
12
11
|
|
|
@@ -31,7 +30,7 @@ import {
|
|
|
31
30
|
type ConvertedBenchmarkSuite,
|
|
32
31
|
type TestFramework,
|
|
33
32
|
} from '../../adapters/types.js';
|
|
34
|
-
import { ExitCodes } from '../../
|
|
33
|
+
import { ExitCodes } from '../../constants.js';
|
|
35
34
|
import { createRunId } from '../../types/core.js';
|
|
36
35
|
import { isError } from '../../utils/type-guards.js';
|
|
37
36
|
|
package/src/cli/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
CsvReporter,
|
|
40
40
|
HumanReporter,
|
|
41
41
|
JsonReporter,
|
|
42
|
+
NyanReporter,
|
|
42
43
|
SimpleReporter,
|
|
43
44
|
} from '../reporters/index.js';
|
|
44
45
|
// Import commands
|
|
@@ -1151,6 +1152,13 @@ const createCliContext = async (
|
|
|
1151
1152
|
}),
|
|
1152
1153
|
);
|
|
1153
1154
|
|
|
1155
|
+
engine.registerReporter(
|
|
1156
|
+
'nyan',
|
|
1157
|
+
new NyanReporter({
|
|
1158
|
+
color: !options.noColor,
|
|
1159
|
+
}),
|
|
1160
|
+
);
|
|
1161
|
+
|
|
1154
1162
|
return {
|
|
1155
1163
|
abortController,
|
|
1156
1164
|
configManager: engine.configManager,
|
package/src/constants.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Engine } from './types/
|
|
1
|
+
import { type Engine } from './types/core.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Supported benchmark file extensions
|
|
@@ -60,6 +60,7 @@ export const Reporters = {
|
|
|
60
60
|
CSV: 'csv',
|
|
61
61
|
HUMAN: 'human',
|
|
62
62
|
JSON: 'json',
|
|
63
|
+
NYAN: 'nyan',
|
|
63
64
|
SIMPLE: 'simple',
|
|
64
65
|
} as const;
|
|
65
66
|
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
export { bootstrap as modestbench } from './bootstrap.js';
|
|
10
10
|
|
|
11
|
+
// Constants
|
|
12
|
+
export { ExitCodes } from './constants.js';
|
|
13
|
+
|
|
11
14
|
// Core engine
|
|
12
15
|
export { ModestBenchEngine } from './core/engine.js';
|
|
13
16
|
export { AccurateEngine, TinybenchEngine } from './core/engines/index.js';
|
package/src/reporters/index.ts
CHANGED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Nyan Cat Reporter
|
|
3
|
+
*
|
|
4
|
+
* Because benchmarking should be more colorful. Displays an animated nyan cat
|
|
5
|
+
* flying through a rainbow trail as benchmarks complete.
|
|
6
|
+
*
|
|
7
|
+
* Based on Mocha's legendary nyan reporter, adapted for the glory of
|
|
8
|
+
* performance measurement.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BenchmarkRun,
|
|
15
|
+
FileResult,
|
|
16
|
+
SuiteResult,
|
|
17
|
+
TaskResult,
|
|
18
|
+
} from '../types/index.js';
|
|
19
|
+
|
|
20
|
+
import { BaseReporter } from '../services/reporter-registry.js';
|
|
21
|
+
import { colors } from '../utils/ansi.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Nyan Cat reporter - because your benchmarks deserve rainbow power
|
|
25
|
+
*/
|
|
26
|
+
export class NyanReporter extends BaseReporter {
|
|
27
|
+
/** Index into rainbow colors for cycling */
|
|
28
|
+
private colorIndex = 0;
|
|
29
|
+
|
|
30
|
+
/** Current file being processed */
|
|
31
|
+
private currentFile = '';
|
|
32
|
+
|
|
33
|
+
/** Current suite being processed */
|
|
34
|
+
private currentSuite = '';
|
|
35
|
+
|
|
36
|
+
/** Total failed tasks */
|
|
37
|
+
private failed = 0;
|
|
38
|
+
|
|
39
|
+
/** Collected failures for summary */
|
|
40
|
+
private failures: Array<{
|
|
41
|
+
error: string;
|
|
42
|
+
file: string;
|
|
43
|
+
suite: string;
|
|
44
|
+
task: string;
|
|
45
|
+
}> = [];
|
|
46
|
+
|
|
47
|
+
/** Number of lines the cat occupies */
|
|
48
|
+
private readonly numberOfLines = 4;
|
|
49
|
+
|
|
50
|
+
/** Total passed tasks */
|
|
51
|
+
private passed = 0;
|
|
52
|
+
|
|
53
|
+
/** Whether the display is active */
|
|
54
|
+
private progressActive = false;
|
|
55
|
+
|
|
56
|
+
/** Quiet mode - suppress output */
|
|
57
|
+
private readonly quiet: boolean;
|
|
58
|
+
|
|
59
|
+
/** Generated rainbow color palette */
|
|
60
|
+
private rainbowColors: number[] = [];
|
|
61
|
+
|
|
62
|
+
/** Width of scoreboard */
|
|
63
|
+
private readonly scoreboardWidth = 5;
|
|
64
|
+
|
|
65
|
+
/** Start time for duration calculation */
|
|
66
|
+
private startTime = 0;
|
|
67
|
+
|
|
68
|
+
/** Animation tick (alternates between frames) */
|
|
69
|
+
private tick = false;
|
|
70
|
+
|
|
71
|
+
/** Rainbow trail storage - one trajectory per cat line */
|
|
72
|
+
private trajectories: string[][] = [[], [], [], []];
|
|
73
|
+
|
|
74
|
+
/** Maximum width of the rainbow trail */
|
|
75
|
+
private trajectoryWidthMax = 0;
|
|
76
|
+
|
|
77
|
+
/** Whether to use colors */
|
|
78
|
+
private readonly useColor: boolean;
|
|
79
|
+
|
|
80
|
+
constructor(
|
|
81
|
+
options: {
|
|
82
|
+
color?: boolean;
|
|
83
|
+
quiet?: boolean;
|
|
84
|
+
} = {},
|
|
85
|
+
) {
|
|
86
|
+
super('nyan', options);
|
|
87
|
+
|
|
88
|
+
this.quiet = options.quiet ?? false;
|
|
89
|
+
|
|
90
|
+
// Auto-detect color support if not explicitly set
|
|
91
|
+
this.useColor =
|
|
92
|
+
options.color ??
|
|
93
|
+
(process.stdout.isTTY &&
|
|
94
|
+
process.env.FORCE_COLOR !== '0' &&
|
|
95
|
+
process.env.NO_COLOR == null);
|
|
96
|
+
|
|
97
|
+
// Generate the rainbow colors on construction
|
|
98
|
+
this.rainbowColors = this.generateColors();
|
|
99
|
+
|
|
100
|
+
// Calculate trajectory width based on terminal width
|
|
101
|
+
// Leave room for scoreboard (5) + cat (11) + some padding
|
|
102
|
+
const termWidth = process.stdout.columns || 80;
|
|
103
|
+
const nyanCatWidth = 11;
|
|
104
|
+
this.trajectoryWidthMax = Math.floor(termWidth * 0.75) - nyanCatWidth;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onEnd(run: BenchmarkRun): void {
|
|
108
|
+
if (this.quiet) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Show cursor and move past the cat
|
|
113
|
+
this.showCursor();
|
|
114
|
+
for (let i = 0; i < this.numberOfLines; i++) {
|
|
115
|
+
process.stdout.write('\n');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Print summary
|
|
119
|
+
this.printEpilogue(run);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onError(error: Error): void {
|
|
123
|
+
if (this.quiet) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Make sure cursor is visible
|
|
128
|
+
this.showCursor();
|
|
129
|
+
|
|
130
|
+
console.error(`\n${colors.red}Error: ${error.message}${colors.reset}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onFileEnd(_result: FileResult): void {
|
|
134
|
+
// Just keep flying
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onFileStart(file: string): void {
|
|
138
|
+
this.currentFile = file;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onStart(_run: BenchmarkRun): void {
|
|
142
|
+
this.startTime = Date.now();
|
|
143
|
+
this.passed = 0;
|
|
144
|
+
this.failed = 0;
|
|
145
|
+
this.failures = [];
|
|
146
|
+
this.colorIndex = 0;
|
|
147
|
+
this.tick = false;
|
|
148
|
+
this.trajectories = [[], [], [], []];
|
|
149
|
+
|
|
150
|
+
if (this.quiet) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Hide cursor for cleaner animation
|
|
155
|
+
this.hideCursor();
|
|
156
|
+
|
|
157
|
+
// Initial draw
|
|
158
|
+
this.draw();
|
|
159
|
+
this.progressActive = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
onSuiteEnd(_result: SuiteResult): void {
|
|
163
|
+
// Keep flying
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onSuiteStart(suite: string): void {
|
|
167
|
+
this.currentSuite = suite;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onTaskResult(result: TaskResult): void {
|
|
171
|
+
if (result.error) {
|
|
172
|
+
this.failed++;
|
|
173
|
+
this.failures.push({
|
|
174
|
+
error: result.error.message || String(result.error),
|
|
175
|
+
file: this.currentFile,
|
|
176
|
+
suite: this.currentSuite,
|
|
177
|
+
task: result.name,
|
|
178
|
+
});
|
|
179
|
+
} else if (!result.aborted) {
|
|
180
|
+
this.passed++;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.quiet) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.draw();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onTaskStart(_task: string): void {
|
|
191
|
+
// The cat flies on results, not starts
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Append a segment to the rainbow trail
|
|
196
|
+
*/
|
|
197
|
+
private appendRainbow(): void {
|
|
198
|
+
const segment = this.tick ? '_' : '-';
|
|
199
|
+
const rainbowified = this.rainbowify(segment);
|
|
200
|
+
|
|
201
|
+
for (let index = 0; index < this.numberOfLines; index++) {
|
|
202
|
+
const trajectory = this.trajectories[index]!;
|
|
203
|
+
if (trajectory.length >= this.trajectoryWidthMax) {
|
|
204
|
+
trajectory.shift();
|
|
205
|
+
}
|
|
206
|
+
trajectory.push(rainbowified);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Move cursor down n lines
|
|
212
|
+
*/
|
|
213
|
+
private cursorDown(n: number): void {
|
|
214
|
+
process.stdout.write(`\x1b[${n}B`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Move cursor up n lines
|
|
219
|
+
*/
|
|
220
|
+
private cursorUp(n: number): void {
|
|
221
|
+
process.stdout.write(`\x1b[${n}A`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Draw the complete nyan cat scene
|
|
226
|
+
*/
|
|
227
|
+
private draw(): void {
|
|
228
|
+
this.appendRainbow();
|
|
229
|
+
this.drawScoreboard();
|
|
230
|
+
this.drawRainbow();
|
|
231
|
+
this.drawNyanCat();
|
|
232
|
+
this.tick = !this.tick;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Draw the nyan cat ASCII art
|
|
237
|
+
*/
|
|
238
|
+
private drawNyanCat(): void {
|
|
239
|
+
const startWidth = this.scoreboardWidth + this.trajectories[0]!.length;
|
|
240
|
+
const dist = `\x1b[${startWidth}C`;
|
|
241
|
+
|
|
242
|
+
process.stdout.write(dist);
|
|
243
|
+
process.stdout.write('_,------,');
|
|
244
|
+
process.stdout.write('\n');
|
|
245
|
+
|
|
246
|
+
process.stdout.write(dist);
|
|
247
|
+
const padding1 = this.tick ? ' ' : ' ';
|
|
248
|
+
process.stdout.write(`_|${padding1}/\\_/\\ `);
|
|
249
|
+
process.stdout.write('\n');
|
|
250
|
+
|
|
251
|
+
process.stdout.write(dist);
|
|
252
|
+
const padding2 = this.tick ? '_' : '__';
|
|
253
|
+
const tail = this.tick ? '~' : '^';
|
|
254
|
+
process.stdout.write(`${tail}|${padding2}${this.face()} `);
|
|
255
|
+
process.stdout.write('\n');
|
|
256
|
+
|
|
257
|
+
process.stdout.write(dist);
|
|
258
|
+
const padding3 = this.tick ? ' ' : ' ';
|
|
259
|
+
process.stdout.write(`${padding3}"" "" `);
|
|
260
|
+
process.stdout.write('\n');
|
|
261
|
+
|
|
262
|
+
this.cursorUp(this.numberOfLines);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Draw the rainbow trail
|
|
267
|
+
*/
|
|
268
|
+
private drawRainbow(): void {
|
|
269
|
+
for (const line of this.trajectories) {
|
|
270
|
+
process.stdout.write(`\x1b[${this.scoreboardWidth}C`);
|
|
271
|
+
process.stdout.write(line.join(''));
|
|
272
|
+
process.stdout.write('\n');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.cursorUp(this.numberOfLines);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Draw the scoreboard showing pass/fail counts
|
|
280
|
+
*/
|
|
281
|
+
private drawScoreboard(): void {
|
|
282
|
+
const draw = (type: 'green' | 'red', n: number) => {
|
|
283
|
+
process.stdout.write(' ');
|
|
284
|
+
if (this.useColor) {
|
|
285
|
+
process.stdout.write(`${colors[type]}${n}${colors.reset}`);
|
|
286
|
+
} else {
|
|
287
|
+
process.stdout.write(String(n));
|
|
288
|
+
}
|
|
289
|
+
process.stdout.write('\n');
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
draw('green', this.passed);
|
|
293
|
+
draw('red', this.failed);
|
|
294
|
+
process.stdout.write('\n');
|
|
295
|
+
process.stdout.write('\n');
|
|
296
|
+
|
|
297
|
+
this.cursorUp(this.numberOfLines);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get the nyan cat's face based on current state
|
|
302
|
+
*/
|
|
303
|
+
private face(): string {
|
|
304
|
+
if (this.failed > 0) {
|
|
305
|
+
return '( x .x)';
|
|
306
|
+
} else if (this.passed > 0) {
|
|
307
|
+
return '( ^ .^)';
|
|
308
|
+
}
|
|
309
|
+
return '( - .-)';
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Generate rainbow colors using sine wave color cycling
|
|
314
|
+
*
|
|
315
|
+
* Uses 256-color palette (colors 16-231 are a 6x6x6 color cube)
|
|
316
|
+
*/
|
|
317
|
+
private generateColors(): number[] {
|
|
318
|
+
const colorList: number[] = [];
|
|
319
|
+
|
|
320
|
+
// Generate 42 colors (6 * 7) cycling through the spectrum
|
|
321
|
+
for (let i = 0; i < 6 * 7; i++) {
|
|
322
|
+
const pi3 = Math.floor(Math.PI / 3);
|
|
323
|
+
const n = i * (1.0 / 6);
|
|
324
|
+
const r = Math.floor(3 * Math.sin(n) + 3);
|
|
325
|
+
const g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
|
|
326
|
+
const b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
|
|
327
|
+
// Calculate 256-color code from RGB values (16 + 36*r + 6*g + b)
|
|
328
|
+
colorList.push(36 * r + 6 * g + b + 16);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return colorList;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Hide the cursor
|
|
336
|
+
*/
|
|
337
|
+
private hideCursor(): void {
|
|
338
|
+
if (process.stdout.isTTY) {
|
|
339
|
+
process.stdout.write('\x1b[?25l');
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Print the epilogue summary after the run
|
|
345
|
+
*/
|
|
346
|
+
private printEpilogue(run: BenchmarkRun): void {
|
|
347
|
+
const duration = Date.now() - this.startTime;
|
|
348
|
+
const durationStr = BaseReporter.formatDuration(duration * 1000000);
|
|
349
|
+
|
|
350
|
+
console.log();
|
|
351
|
+
console.log(
|
|
352
|
+
` ${this.useColor ? colors.green : ''}${this.passed} passing${this.useColor ? colors.reset : ''} ${this.useColor ? colors.gray : ''}(${durationStr})${this.useColor ? colors.reset : ''}`,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
if (this.failed > 0) {
|
|
356
|
+
console.log(
|
|
357
|
+
` ${this.useColor ? colors.red : ''}${this.failed} failing${this.useColor ? colors.reset : ''}`,
|
|
358
|
+
);
|
|
359
|
+
console.log();
|
|
360
|
+
|
|
361
|
+
// Print failure details
|
|
362
|
+
for (let i = 0; i < this.failures.length; i++) {
|
|
363
|
+
const failure = this.failures[i]!;
|
|
364
|
+
console.log(
|
|
365
|
+
` ${i + 1}) ${failure.suite === 'default' ? '' : failure.suite + ' > '}${failure.task}`,
|
|
366
|
+
);
|
|
367
|
+
console.log(
|
|
368
|
+
` ${this.useColor ? colors.red : ''}${failure.error}${this.useColor ? colors.reset : ''}`,
|
|
369
|
+
);
|
|
370
|
+
console.log();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Show total files/suites for context
|
|
375
|
+
let totalSuites = 0;
|
|
376
|
+
for (const file of run.files) {
|
|
377
|
+
totalSuites += file.suites.length;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
console.log();
|
|
381
|
+
console.log(
|
|
382
|
+
` ${this.useColor ? colors.gray : ''}Files: ${run.files.length} | Suites: ${totalSuites} | Tasks: ${this.passed + this.failed}${this.useColor ? colors.reset : ''}`,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Apply rainbow coloring to a string
|
|
388
|
+
*/
|
|
389
|
+
private rainbowify(str: string): string {
|
|
390
|
+
if (!this.useColor) {
|
|
391
|
+
return str;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const color =
|
|
395
|
+
this.rainbowColors[this.colorIndex % this.rainbowColors.length]!;
|
|
396
|
+
this.colorIndex += 1;
|
|
397
|
+
|
|
398
|
+
return `\x1b[38;5;${color}m${str}\x1b[0m`;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Show the cursor
|
|
403
|
+
*/
|
|
404
|
+
private showCursor(): void {
|
|
405
|
+
if (process.stdout.isTTY) {
|
|
406
|
+
process.stdout.write('\x1b[?25h');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
package/src/types/core.ts
CHANGED
|
@@ -37,6 +37,20 @@ export type {
|
|
|
37
37
|
BenchmarkTaskInput,
|
|
38
38
|
} from '../core/benchmark-schema.js';
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Benchmark file structure after parsing
|
|
42
|
+
*/
|
|
43
|
+
export interface BenchmarkFile {
|
|
44
|
+
/** Raw file content */
|
|
45
|
+
readonly content: string;
|
|
46
|
+
/** Parsed exports from the file */
|
|
47
|
+
readonly exports: unknown;
|
|
48
|
+
/** Absolute path to the file */
|
|
49
|
+
readonly filePath: string;
|
|
50
|
+
/** File metadata */
|
|
51
|
+
readonly metadata: FileMetadata;
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
/**
|
|
41
55
|
* ModestBench Core Types
|
|
42
56
|
*
|
|
@@ -52,20 +66,6 @@ export type {
|
|
|
52
66
|
// Re-export identifier helper functions
|
|
53
67
|
export { createRunId, createTaskId } from '../utils/identifiers.js';
|
|
54
68
|
|
|
55
|
-
/**
|
|
56
|
-
* Benchmark file structure after parsing
|
|
57
|
-
*/
|
|
58
|
-
export interface BenchmarkFile {
|
|
59
|
-
/** Raw file content */
|
|
60
|
-
readonly content: string;
|
|
61
|
-
/** Parsed exports from the file */
|
|
62
|
-
readonly exports: unknown;
|
|
63
|
-
/** Absolute path to the file */
|
|
64
|
-
readonly filePath: string;
|
|
65
|
-
/** File metadata */
|
|
66
|
-
readonly metadata: FileMetadata;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
69
|
/**
|
|
70
70
|
* Represents a complete benchmark run across multiple files
|
|
71
71
|
*/
|
|
@@ -128,6 +128,8 @@ export interface CpuInfo {
|
|
|
128
128
|
readonly speed: number;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
export type Engine = 'accurate' | 'tinybench';
|
|
132
|
+
|
|
131
133
|
/**
|
|
132
134
|
* Environment information captured during benchmark execution
|
|
133
135
|
*/
|
package/src/types/index.ts
CHANGED
package/dist/types/cli.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ModestBench CLI Types
|
|
4
|
-
*
|
|
5
|
-
* Defines types specific to the command-line interface, including command
|
|
6
|
-
* definitions, argument parsing, and CLI-specific configuration structures.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ExitCodes = void 0;
|
|
10
|
-
const constants_js_1 = require("../constants.cjs");
|
|
11
|
-
Object.defineProperty(exports, "ExitCodes", { enumerable: true, get: function () { return constants_js_1.ExitCodes; } });
|
|
12
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/types/cli.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/types/cli.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mDAA4C;AAEnC,0FAFA,wBAAS,OAEA"}
|
package/dist/types/cli.d.cts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ModestBench CLI Types
|
|
3
|
-
*
|
|
4
|
-
* Defines types specific to the command-line interface, including command
|
|
5
|
-
* definitions, argument parsing, and CLI-specific configuration structures.
|
|
6
|
-
*/
|
|
7
|
-
import { ExitCodes } from "../constants.cjs";
|
|
8
|
-
export { ExitCodes };
|
|
9
|
-
/**
|
|
10
|
-
* CLI argument specification for a command
|
|
11
|
-
*/
|
|
12
|
-
export interface ArgumentSpec {
|
|
13
|
-
/** Short alias */
|
|
14
|
-
readonly alias?: string;
|
|
15
|
-
/** Choices for string arguments */
|
|
16
|
-
readonly choices?: string[];
|
|
17
|
-
/** Default value */
|
|
18
|
-
readonly default?: unknown;
|
|
19
|
-
/** Argument description */
|
|
20
|
-
readonly description: string;
|
|
21
|
-
/** Argument name */
|
|
22
|
-
readonly name: string;
|
|
23
|
-
/** Whether argument is required */
|
|
24
|
-
readonly required?: boolean;
|
|
25
|
-
/** Argument type */
|
|
26
|
-
readonly type: 'array' | 'boolean' | 'number' | 'string';
|
|
27
|
-
/** Validation function */
|
|
28
|
-
readonly validate?: (value: unknown) => boolean | string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Parsed command-line arguments
|
|
32
|
-
*/
|
|
33
|
-
export interface CommandArguments {
|
|
34
|
-
/** Positional arguments */
|
|
35
|
-
readonly _: string[];
|
|
36
|
-
/** Named arguments */
|
|
37
|
-
readonly [key: string]: unknown;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* CLI command specification
|
|
41
|
-
*/
|
|
42
|
-
export interface CommandSpec {
|
|
43
|
-
/** Command aliases */
|
|
44
|
-
readonly aliases?: string[];
|
|
45
|
-
/** Command description */
|
|
46
|
-
readonly description: string;
|
|
47
|
-
/** Examples of command usage */
|
|
48
|
-
readonly examples?: string[];
|
|
49
|
-
/** Command name */
|
|
50
|
-
readonly name: string;
|
|
51
|
-
/** Named arguments */
|
|
52
|
-
readonly options?: ArgumentSpec[];
|
|
53
|
-
/** Positional arguments */
|
|
54
|
-
readonly positional?: ArgumentSpec[];
|
|
55
|
-
/** Subcommands */
|
|
56
|
-
readonly subcommands?: CommandSpec[];
|
|
57
|
-
}
|
|
58
|
-
export type Engine = 'accurate' | 'tinybench';
|
|
59
|
-
export type ExitCode = (typeof ExitCodes)[keyof typeof ExitCodes];
|
|
60
|
-
/**
|
|
61
|
-
* Progress display options
|
|
62
|
-
*/
|
|
63
|
-
export interface ProgressDisplayOptions {
|
|
64
|
-
/** Progress bar width */
|
|
65
|
-
readonly barWidth: number;
|
|
66
|
-
/** Show current file being processed */
|
|
67
|
-
readonly showCurrentFile: boolean;
|
|
68
|
-
/** Show progress bars */
|
|
69
|
-
readonly showProgress: boolean;
|
|
70
|
-
/** Show estimated time remaining */
|
|
71
|
-
readonly showTimeRemaining: boolean;
|
|
72
|
-
/** Update interval in milliseconds */
|
|
73
|
-
readonly updateInterval: number;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=cli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