benchforge 0.1.1 → 0.1.3
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/README.md +15 -129
- package/dist/BenchRunner-BLfGX2wQ.d.mts +225 -0
- package/dist/{TimingUtils-D4z1jpp2.mjs → TimingUtils-ClclVQ7E.mjs} +276 -278
- package/dist/TimingUtils-ClclVQ7E.mjs.map +1 -0
- package/dist/bin/benchforge.d.mts +1 -0
- package/dist/bin/benchforge.mjs +1 -1
- package/dist/index.d.mts +711 -0
- package/dist/index.mjs +2 -2
- package/dist/runners/WorkerScript.d.mts +39 -0
- package/dist/runners/WorkerScript.mjs +1 -1
- package/dist/{src-cYpHvc40.mjs → src-JGOI6_Sc.mjs} +22 -23
- package/dist/src-JGOI6_Sc.mjs.map +1 -0
- package/package.json +1 -1
- package/src/StandardSections.ts +1 -8
- package/src/browser/BrowserHeapSampler.ts +3 -2
- package/src/cli/CliArgs.ts +11 -14
- package/src/cli/RunBenchCLI.ts +1 -4
- package/src/runners/BasicRunner.ts +0 -4
- package/src/table-util/Formatters.ts +1 -1
- package/dist/TimingUtils-D4z1jpp2.mjs.map +0 -1
- package/dist/src-cYpHvc40.mjs.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import { a as MeasuredResults, i as BenchmarkSpec, n as BenchGroup, r as BenchSuite, t as RunnerOptions } from "./BenchRunner-BLfGX2wQ.mjs";
|
|
2
|
+
import { Alignment } from "table";
|
|
3
|
+
import { Argv, InferredOptionTypes } from "yargs";
|
|
4
|
+
import * as node_http0 from "node:http";
|
|
5
|
+
|
|
6
|
+
//#region src/BenchMatrix.d.ts
|
|
7
|
+
/** Stateless variant - called each iteration with case data */
|
|
8
|
+
type VariantFn<T = unknown> = (caseData: T) => void;
|
|
9
|
+
/** Stateful variant - setup once, run many */
|
|
10
|
+
interface StatefulVariant<T = unknown, S = unknown> {
|
|
11
|
+
setup: (caseData: T) => S | Promise<S>;
|
|
12
|
+
run: (state: S) => void;
|
|
13
|
+
}
|
|
14
|
+
/** A variant is either a plain function or a stateful setup+run pair */
|
|
15
|
+
type Variant<T = unknown, S = unknown> = VariantFn<T> | StatefulVariant<T, S>;
|
|
16
|
+
/** Variant with any state type - used in BenchMatrix to allow mixed variants */
|
|
17
|
+
type AnyVariant<T = unknown> = VariantFn<T> | StatefulVariant<T, any>;
|
|
18
|
+
/** Result from casesModule.loadCase() */
|
|
19
|
+
interface LoadedCase<T = unknown> {
|
|
20
|
+
data: T;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
interface MatrixDefaults {
|
|
24
|
+
warmup?: number;
|
|
25
|
+
maxTime?: number;
|
|
26
|
+
iterations?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Bench matrix configuration */
|
|
29
|
+
interface BenchMatrix<T = unknown> {
|
|
30
|
+
name: string;
|
|
31
|
+
variantDir?: string;
|
|
32
|
+
variants?: Record<string, AnyVariant<T>>;
|
|
33
|
+
cases?: string[];
|
|
34
|
+
casesModule?: string;
|
|
35
|
+
baselineDir?: string;
|
|
36
|
+
baselineVariant?: string;
|
|
37
|
+
defaults?: MatrixDefaults;
|
|
38
|
+
}
|
|
39
|
+
/** Collection of matrices */
|
|
40
|
+
interface MatrixSuite {
|
|
41
|
+
name: string;
|
|
42
|
+
matrices: BenchMatrix<any>[];
|
|
43
|
+
}
|
|
44
|
+
/** Results for a single variant across all cases */
|
|
45
|
+
interface VariantResult {
|
|
46
|
+
id: string;
|
|
47
|
+
cases: CaseResult[];
|
|
48
|
+
}
|
|
49
|
+
/** Results for a single (variant, case) pair */
|
|
50
|
+
interface CaseResult {
|
|
51
|
+
caseId: string;
|
|
52
|
+
measured: MeasuredResults;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
baseline?: MeasuredResults;
|
|
55
|
+
deltaPercent?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Results from running a matrix */
|
|
58
|
+
interface MatrixResults {
|
|
59
|
+
name: string;
|
|
60
|
+
variants: VariantResult[];
|
|
61
|
+
}
|
|
62
|
+
/** @return true if variant is a StatefulVariant (has setup + run) */
|
|
63
|
+
declare function isStatefulVariant<T, S>(v: Variant<T, S>): v is StatefulVariant<T, S>;
|
|
64
|
+
/** Options for runMatrix */
|
|
65
|
+
interface RunMatrixOptions {
|
|
66
|
+
iterations?: number;
|
|
67
|
+
maxTime?: number;
|
|
68
|
+
warmup?: number;
|
|
69
|
+
useWorker?: boolean;
|
|
70
|
+
filteredCases?: string[];
|
|
71
|
+
filteredVariants?: string[];
|
|
72
|
+
collect?: boolean;
|
|
73
|
+
cpuCounters?: boolean;
|
|
74
|
+
traceOpt?: boolean;
|
|
75
|
+
noSettle?: boolean;
|
|
76
|
+
pauseFirst?: number;
|
|
77
|
+
pauseInterval?: number;
|
|
78
|
+
pauseDuration?: number;
|
|
79
|
+
gcStats?: boolean;
|
|
80
|
+
heapSample?: boolean;
|
|
81
|
+
heapInterval?: number;
|
|
82
|
+
heapDepth?: number;
|
|
83
|
+
}
|
|
84
|
+
/** Run a BenchMatrix with inline variants or variantDir */
|
|
85
|
+
declare function runMatrix<T>(matrix: BenchMatrix<T>, options?: RunMatrixOptions): Promise<MatrixResults>;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/table-util/TableReport.d.ts
|
|
88
|
+
type AnyColumn<T> = Column<T> | DiffColumn<T>;
|
|
89
|
+
/** Column with optional formatter */
|
|
90
|
+
interface Column<T> extends ColumnFormat<T> {
|
|
91
|
+
formatter?: (value: unknown) => string | null;
|
|
92
|
+
diffKey?: undefined;
|
|
93
|
+
}
|
|
94
|
+
/** Comparison column against baseline */
|
|
95
|
+
interface DiffColumn<T> extends ColumnFormat<T> {
|
|
96
|
+
diffFormatter?: (value: unknown, baseline: unknown) => string | null;
|
|
97
|
+
formatter?: undefined;
|
|
98
|
+
/** Key for comparison value against baseline */
|
|
99
|
+
diffKey: keyof T;
|
|
100
|
+
}
|
|
101
|
+
interface ColumnFormat<T> {
|
|
102
|
+
key: keyof T;
|
|
103
|
+
title: string;
|
|
104
|
+
alignment?: Alignment;
|
|
105
|
+
width?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Table headers and configuration */
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/BenchmarkReport.d.ts
|
|
110
|
+
/** Benchmark results with optional baseline for comparison */
|
|
111
|
+
interface ReportGroup {
|
|
112
|
+
name: string;
|
|
113
|
+
reports: BenchmarkReport[];
|
|
114
|
+
baseline?: BenchmarkReport;
|
|
115
|
+
}
|
|
116
|
+
/** Results from a single benchmark run */
|
|
117
|
+
interface BenchmarkReport {
|
|
118
|
+
name: string;
|
|
119
|
+
measuredResults: MeasuredResults;
|
|
120
|
+
metadata?: UnknownRecord;
|
|
121
|
+
}
|
|
122
|
+
interface ReportColumnGroup<T> {
|
|
123
|
+
groupTitle?: string;
|
|
124
|
+
columns: ReportColumn<T>[];
|
|
125
|
+
}
|
|
126
|
+
type ReportColumn<T> = AnyColumn<T> & {
|
|
127
|
+
/** Add diff column after this column when baseline exists */comparable?: boolean; /** Set true for throughput metrics where higher values are better (e.g., lines/sec) */
|
|
128
|
+
higherIsBetter?: boolean;
|
|
129
|
+
};
|
|
130
|
+
/** Maps benchmark results to table columns */
|
|
131
|
+
interface ResultsMapper<T extends Record<string, any> = Record<string, any>> {
|
|
132
|
+
extract(results: MeasuredResults, metadata?: UnknownRecord): T;
|
|
133
|
+
columns(): ReportColumnGroup<T>[];
|
|
134
|
+
}
|
|
135
|
+
type UnknownRecord = Record<string, unknown>;
|
|
136
|
+
/** @return formatted table report with optional baseline comparisons */
|
|
137
|
+
declare function reportResults<S extends ReadonlyArray<ResultsMapper<any>>>(groups: ReportGroup[], sections: S): string;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/cli/CliArgs.d.ts
|
|
140
|
+
type Configure<T> = (yargs: Argv) => Argv<T>;
|
|
141
|
+
/** CLI args type inferred from cliOptions */
|
|
142
|
+
type DefaultCliArgs = InferredOptionTypes<typeof cliOptions>;
|
|
143
|
+
declare const cliOptions: {
|
|
144
|
+
readonly time: {
|
|
145
|
+
readonly type: "number";
|
|
146
|
+
readonly default: 0.642;
|
|
147
|
+
readonly requiresArg: true;
|
|
148
|
+
readonly describe: "test duration in seconds";
|
|
149
|
+
};
|
|
150
|
+
readonly cpu: {
|
|
151
|
+
readonly type: "boolean";
|
|
152
|
+
readonly default: false;
|
|
153
|
+
readonly describe: "CPU counter measurements (requires root)";
|
|
154
|
+
};
|
|
155
|
+
readonly collect: {
|
|
156
|
+
readonly type: "boolean";
|
|
157
|
+
readonly default: false;
|
|
158
|
+
readonly describe: "force GC after each iteration";
|
|
159
|
+
};
|
|
160
|
+
readonly "gc-stats": {
|
|
161
|
+
readonly type: "boolean";
|
|
162
|
+
readonly default: false;
|
|
163
|
+
readonly describe: "collect GC statistics (Node: --trace-gc-nvp, browser: CDP tracing)";
|
|
164
|
+
};
|
|
165
|
+
readonly profile: {
|
|
166
|
+
readonly type: "boolean";
|
|
167
|
+
readonly default: false;
|
|
168
|
+
readonly describe: "run once for profiling";
|
|
169
|
+
};
|
|
170
|
+
readonly filter: {
|
|
171
|
+
readonly type: "string";
|
|
172
|
+
readonly requiresArg: true;
|
|
173
|
+
readonly describe: "filter benchmarks by regex or substring";
|
|
174
|
+
};
|
|
175
|
+
readonly all: {
|
|
176
|
+
readonly type: "boolean";
|
|
177
|
+
readonly default: false;
|
|
178
|
+
readonly describe: "run all cases (ignore defaultCases)";
|
|
179
|
+
};
|
|
180
|
+
readonly worker: {
|
|
181
|
+
readonly type: "boolean";
|
|
182
|
+
readonly default: true;
|
|
183
|
+
readonly describe: "run in worker process for isolation (default: true)";
|
|
184
|
+
};
|
|
185
|
+
readonly adaptive: {
|
|
186
|
+
readonly type: "boolean";
|
|
187
|
+
readonly default: false;
|
|
188
|
+
readonly describe: "adaptive sampling (experimental)";
|
|
189
|
+
};
|
|
190
|
+
readonly "min-time": {
|
|
191
|
+
readonly type: "number";
|
|
192
|
+
readonly default: 1;
|
|
193
|
+
readonly describe: "minimum time before adaptive convergence can stop";
|
|
194
|
+
};
|
|
195
|
+
readonly convergence: {
|
|
196
|
+
readonly type: "number";
|
|
197
|
+
readonly default: 95;
|
|
198
|
+
readonly describe: "adaptive confidence threshold (0-100)";
|
|
199
|
+
};
|
|
200
|
+
readonly warmup: {
|
|
201
|
+
readonly type: "number";
|
|
202
|
+
readonly default: 0;
|
|
203
|
+
readonly describe: "warmup iterations before measurement";
|
|
204
|
+
};
|
|
205
|
+
readonly html: {
|
|
206
|
+
readonly type: "boolean";
|
|
207
|
+
readonly default: false;
|
|
208
|
+
readonly describe: "generate HTML report and open in browser";
|
|
209
|
+
};
|
|
210
|
+
readonly "export-html": {
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
readonly requiresArg: true;
|
|
213
|
+
readonly describe: "export HTML report to specified file";
|
|
214
|
+
};
|
|
215
|
+
readonly json: {
|
|
216
|
+
readonly type: "string";
|
|
217
|
+
readonly requiresArg: true;
|
|
218
|
+
readonly describe: "export benchmark data to JSON file";
|
|
219
|
+
};
|
|
220
|
+
readonly perfetto: {
|
|
221
|
+
readonly type: "string";
|
|
222
|
+
readonly requiresArg: true;
|
|
223
|
+
readonly describe: "export Perfetto trace file (view at ui.perfetto.dev)";
|
|
224
|
+
};
|
|
225
|
+
readonly "trace-opt": {
|
|
226
|
+
readonly type: "boolean";
|
|
227
|
+
readonly default: false;
|
|
228
|
+
readonly describe: "trace V8 optimization tiers (requires --allow-natives-syntax)";
|
|
229
|
+
};
|
|
230
|
+
readonly "skip-settle": {
|
|
231
|
+
readonly type: "boolean";
|
|
232
|
+
readonly default: false;
|
|
233
|
+
readonly describe: "skip post-warmup settle time (see V8 optimization cold start)";
|
|
234
|
+
};
|
|
235
|
+
readonly "pause-first": {
|
|
236
|
+
readonly type: "number";
|
|
237
|
+
readonly describe: "iterations before first pause (then pause-interval applies)";
|
|
238
|
+
};
|
|
239
|
+
readonly "pause-interval": {
|
|
240
|
+
readonly type: "number";
|
|
241
|
+
readonly default: 0;
|
|
242
|
+
readonly describe: "iterations between pauses for V8 optimization (0 to disable)";
|
|
243
|
+
};
|
|
244
|
+
readonly "pause-duration": {
|
|
245
|
+
readonly type: "number";
|
|
246
|
+
readonly default: 100;
|
|
247
|
+
readonly describe: "pause duration in ms for V8 optimization";
|
|
248
|
+
};
|
|
249
|
+
readonly batches: {
|
|
250
|
+
readonly type: "number";
|
|
251
|
+
readonly default: 1;
|
|
252
|
+
readonly describe: "divide time into N batches, alternating baseline/current order";
|
|
253
|
+
};
|
|
254
|
+
readonly iterations: {
|
|
255
|
+
readonly type: "number";
|
|
256
|
+
readonly requiresArg: true;
|
|
257
|
+
readonly describe: "exact number of iterations (overrides --time)";
|
|
258
|
+
};
|
|
259
|
+
readonly "heap-sample": {
|
|
260
|
+
readonly type: "boolean";
|
|
261
|
+
readonly default: false;
|
|
262
|
+
readonly describe: "heap sampling allocation attribution (includes garbage)";
|
|
263
|
+
};
|
|
264
|
+
readonly "heap-interval": {
|
|
265
|
+
readonly type: "number";
|
|
266
|
+
readonly default: 32768;
|
|
267
|
+
readonly describe: "heap sampling interval in bytes";
|
|
268
|
+
};
|
|
269
|
+
readonly "heap-depth": {
|
|
270
|
+
readonly type: "number";
|
|
271
|
+
readonly default: 64;
|
|
272
|
+
readonly describe: "heap sampling stack depth";
|
|
273
|
+
};
|
|
274
|
+
readonly "heap-rows": {
|
|
275
|
+
readonly type: "number";
|
|
276
|
+
readonly default: 20;
|
|
277
|
+
readonly describe: "top allocation sites to show";
|
|
278
|
+
};
|
|
279
|
+
readonly "heap-stack": {
|
|
280
|
+
readonly type: "number";
|
|
281
|
+
readonly default: 3;
|
|
282
|
+
readonly describe: "call stack depth to display";
|
|
283
|
+
};
|
|
284
|
+
readonly "heap-verbose": {
|
|
285
|
+
readonly type: "boolean";
|
|
286
|
+
readonly default: false;
|
|
287
|
+
readonly describe: "verbose output with file:// paths and line numbers";
|
|
288
|
+
};
|
|
289
|
+
readonly "heap-user-only": {
|
|
290
|
+
readonly type: "boolean";
|
|
291
|
+
readonly default: false;
|
|
292
|
+
readonly describe: "filter to user code only (hide node internals)";
|
|
293
|
+
};
|
|
294
|
+
readonly url: {
|
|
295
|
+
readonly type: "string";
|
|
296
|
+
readonly requiresArg: true;
|
|
297
|
+
readonly describe: "page URL for browser profiling (enables browser mode)";
|
|
298
|
+
};
|
|
299
|
+
readonly headless: {
|
|
300
|
+
readonly type: "boolean";
|
|
301
|
+
readonly default: true;
|
|
302
|
+
readonly describe: "run browser in headless mode";
|
|
303
|
+
};
|
|
304
|
+
readonly timeout: {
|
|
305
|
+
readonly type: "number";
|
|
306
|
+
readonly default: 60;
|
|
307
|
+
readonly describe: "browser page timeout in seconds";
|
|
308
|
+
};
|
|
309
|
+
readonly "chrome-args": {
|
|
310
|
+
readonly type: "string";
|
|
311
|
+
readonly requiresArg: true;
|
|
312
|
+
readonly describe: "extra Chromium flags (space-separated)";
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
/** @return yargs with standard benchmark options */
|
|
316
|
+
declare function defaultCliArgs(yargsInstance: Argv): Argv<DefaultCliArgs>;
|
|
317
|
+
/** @return parsed command line arguments */
|
|
318
|
+
declare function parseCliArgs<T = DefaultCliArgs>(args: string[], configure?: Configure<T>): T;
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/html/Types.d.ts
|
|
321
|
+
/** Data passed to the HTML report generator */
|
|
322
|
+
interface ReportData {
|
|
323
|
+
groups: GroupData[];
|
|
324
|
+
metadata: {
|
|
325
|
+
timestamp: string;
|
|
326
|
+
bencherVersion: string;
|
|
327
|
+
cliArgs?: Record<string, unknown>;
|
|
328
|
+
gcTrackingEnabled?: boolean;
|
|
329
|
+
currentVersion?: GitVersion;
|
|
330
|
+
baselineVersion?: GitVersion;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
interface GroupData {
|
|
334
|
+
name: string;
|
|
335
|
+
baseline?: BenchmarkData;
|
|
336
|
+
benchmarks: BenchmarkData[];
|
|
337
|
+
}
|
|
338
|
+
interface BenchmarkData {
|
|
339
|
+
name: string;
|
|
340
|
+
samples: number[];
|
|
341
|
+
warmupSamples?: number[];
|
|
342
|
+
allocationSamples?: number[];
|
|
343
|
+
heapSamples?: number[];
|
|
344
|
+
gcEvents?: GcEvent[];
|
|
345
|
+
optSamples?: number[];
|
|
346
|
+
pausePoints?: PausePoint[];
|
|
347
|
+
stats: {
|
|
348
|
+
min: number;
|
|
349
|
+
max: number;
|
|
350
|
+
avg: number;
|
|
351
|
+
p50: number;
|
|
352
|
+
p75: number;
|
|
353
|
+
p99: number;
|
|
354
|
+
p999: number;
|
|
355
|
+
};
|
|
356
|
+
heapSize?: {
|
|
357
|
+
min: number;
|
|
358
|
+
max: number;
|
|
359
|
+
avg: number;
|
|
360
|
+
};
|
|
361
|
+
sectionStats?: FormattedStat[];
|
|
362
|
+
comparisonCI?: DifferenceCI;
|
|
363
|
+
}
|
|
364
|
+
interface FormattedStat {
|
|
365
|
+
label: string;
|
|
366
|
+
value: string;
|
|
367
|
+
groupTitle?: string;
|
|
368
|
+
}
|
|
369
|
+
interface GcEvent {
|
|
370
|
+
offset: number;
|
|
371
|
+
duration: number;
|
|
372
|
+
}
|
|
373
|
+
interface PausePoint {
|
|
374
|
+
sampleIndex: number;
|
|
375
|
+
durationMs: number;
|
|
376
|
+
}
|
|
377
|
+
interface GitVersion {
|
|
378
|
+
hash: string;
|
|
379
|
+
date: string;
|
|
380
|
+
dirty?: boolean;
|
|
381
|
+
}
|
|
382
|
+
type CIDirection = "faster" | "slower" | "uncertain";
|
|
383
|
+
interface HistogramBin {
|
|
384
|
+
x: number;
|
|
385
|
+
count: number;
|
|
386
|
+
}
|
|
387
|
+
interface DifferenceCI {
|
|
388
|
+
percent: number;
|
|
389
|
+
ci: [number, number];
|
|
390
|
+
direction: CIDirection;
|
|
391
|
+
histogram?: HistogramBin[];
|
|
392
|
+
}
|
|
393
|
+
interface HtmlReportOptions {
|
|
394
|
+
openBrowser: boolean;
|
|
395
|
+
outputPath?: string;
|
|
396
|
+
}
|
|
397
|
+
interface HtmlReportResult {
|
|
398
|
+
reportDir: string;
|
|
399
|
+
server?: node_http0.Server;
|
|
400
|
+
closeServer?: () => void;
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/html/HtmlReport.d.ts
|
|
404
|
+
/** Generate HTML report from prepared data and optionally open in browser */
|
|
405
|
+
declare function generateHtmlReport(data: ReportData, options: HtmlReportOptions): Promise<HtmlReportResult>;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/html/HtmlTemplate.d.ts
|
|
408
|
+
/** Format ISO date as local time with UTC: "Jan 9, 2026, 3:45 PM (2026-01-09T23:45:00Z)" */
|
|
409
|
+
declare function formatDateWithTimezone(isoDate: string): string;
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/GitUtils.d.ts
|
|
412
|
+
/** Get current git version info. For dirty repos, uses most recent modified file date. */
|
|
413
|
+
declare function getCurrentGitVersion(): GitVersion | undefined;
|
|
414
|
+
/** Read baseline version from .baseline-version file */
|
|
415
|
+
declare function getBaselineVersion(baselineDir?: string): GitVersion | undefined;
|
|
416
|
+
/** Format git version for display: "abc1234 (Jan 9, 2026, 3:45 PM)" or "abc1234*" if dirty */
|
|
417
|
+
declare function formatGitVersion(version: GitVersion): string;
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/heap-sample/HeapSampleReport.d.ts
|
|
420
|
+
interface CallFrame {
|
|
421
|
+
fn: string;
|
|
422
|
+
url: string;
|
|
423
|
+
line: number;
|
|
424
|
+
col: number;
|
|
425
|
+
}
|
|
426
|
+
type UserCodeFilter = (site: CallFrame) => boolean;
|
|
427
|
+
interface HeapReportOptions {
|
|
428
|
+
topN: number;
|
|
429
|
+
stackDepth?: number;
|
|
430
|
+
verbose?: boolean;
|
|
431
|
+
userOnly?: boolean;
|
|
432
|
+
isUserCode?: UserCodeFilter;
|
|
433
|
+
totalAll?: number;
|
|
434
|
+
totalUserCode?: number;
|
|
435
|
+
sampleCount?: number;
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/matrix/MatrixReport.d.ts
|
|
439
|
+
/** Custom column definition for extra computed metrics */
|
|
440
|
+
interface ExtraColumn {
|
|
441
|
+
key: string;
|
|
442
|
+
title: string;
|
|
443
|
+
groupTitle?: string;
|
|
444
|
+
extract: (caseResult: CaseResult) => unknown;
|
|
445
|
+
formatter?: (value: unknown) => string;
|
|
446
|
+
}
|
|
447
|
+
/** Options for matrix report generation */
|
|
448
|
+
interface MatrixReportOptions {
|
|
449
|
+
extraColumns?: ExtraColumn[];
|
|
450
|
+
sections?: ResultsMapper[];
|
|
451
|
+
variantTitle?: string;
|
|
452
|
+
}
|
|
453
|
+
/** Format matrix results as one table per case */
|
|
454
|
+
declare function reportMatrixResults(results: MatrixResults, options?: MatrixReportOptions): string;
|
|
455
|
+
/** GC statistics columns - derived from gcStatsSection for consistency */
|
|
456
|
+
declare const gcStatsColumns: ExtraColumn[];
|
|
457
|
+
/** GC pause time column */
|
|
458
|
+
declare const gcPauseColumn: ExtraColumn;
|
|
459
|
+
/** Heap sampling total bytes column */
|
|
460
|
+
declare const heapTotalColumn: ExtraColumn;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/cli/RunBenchCLI.d.ts
|
|
463
|
+
/** Parse CLI with custom configuration */
|
|
464
|
+
declare function parseBenchArgs<T = DefaultCliArgs>(configureArgs?: Configure<T>): T & DefaultCliArgs;
|
|
465
|
+
/** Run suite with CLI arguments */
|
|
466
|
+
declare function runBenchmarks(suite: BenchSuite, args: DefaultCliArgs): Promise<ReportGroup[]>;
|
|
467
|
+
/** Generate table with standard sections */
|
|
468
|
+
declare function defaultReport(groups: ReportGroup[], args: DefaultCliArgs): string;
|
|
469
|
+
/** Run benchmarks, display table, and optionally generate HTML report */
|
|
470
|
+
declare function benchExports(suite: BenchSuite, args: DefaultCliArgs): Promise<void>;
|
|
471
|
+
/** Print heap allocation reports for benchmarks with heap profiles */
|
|
472
|
+
declare function printHeapReports(groups: ReportGroup[], options: HeapReportOptions): void;
|
|
473
|
+
/** Run benchmarks and display table. Suite is optional with --url (browser mode). */
|
|
474
|
+
declare function runDefaultBench(suite?: BenchSuite, configureArgs?: Configure<any>): Promise<void>;
|
|
475
|
+
/** Log V8 optimization tier distribution and deoptimizations */
|
|
476
|
+
declare function reportOptStatus(groups: ReportGroup[]): void;
|
|
477
|
+
/** @return true if any result has the specified field with a defined value */
|
|
478
|
+
declare function hasField(results: ReportGroup[], field: keyof MeasuredResults): boolean;
|
|
479
|
+
interface ExportOptions {
|
|
480
|
+
results: ReportGroup[];
|
|
481
|
+
args: DefaultCliArgs;
|
|
482
|
+
sections?: any[];
|
|
483
|
+
suiteName?: string;
|
|
484
|
+
currentVersion?: GitVersion;
|
|
485
|
+
baselineVersion?: GitVersion;
|
|
486
|
+
}
|
|
487
|
+
/** Export reports (HTML, JSON, Perfetto) based on CLI args */
|
|
488
|
+
declare function exportReports(options: ExportOptions): Promise<void>;
|
|
489
|
+
/** Run matrix suite with CLI arguments.
|
|
490
|
+
* no options ==> defaultCases/defaultVariants, --filter ==> subset of defaults,
|
|
491
|
+
* --all --filter ==> subset of all, --all ==> all cases/variants */
|
|
492
|
+
declare function runMatrixSuite(suite: MatrixSuite, args: DefaultCliArgs): Promise<MatrixResults[]>;
|
|
493
|
+
/** Convert CLI args to matrix run options */
|
|
494
|
+
declare function cliToMatrixOptions(args: DefaultCliArgs): RunMatrixOptions;
|
|
495
|
+
/** Generate report for matrix results. Uses same sections as regular benchmarks. */
|
|
496
|
+
declare function defaultMatrixReport(results: MatrixResults[], reportOptions?: MatrixReportOptions, args?: DefaultCliArgs): string;
|
|
497
|
+
/** Run matrix suite with full CLI handling (parse, run, report, export) */
|
|
498
|
+
declare function runDefaultMatrixBench(suite: MatrixSuite, configureArgs?: Configure<any>, reportOptions?: MatrixReportOptions): Promise<void>;
|
|
499
|
+
/** Convert MatrixResults to ReportGroup[] for export compatibility */
|
|
500
|
+
declare function matrixToReportGroups(results: MatrixResults[]): ReportGroup[];
|
|
501
|
+
interface MatrixExportOptions {
|
|
502
|
+
sections?: any[];
|
|
503
|
+
currentVersion?: GitVersion;
|
|
504
|
+
baselineVersion?: GitVersion;
|
|
505
|
+
}
|
|
506
|
+
/** Run matrix benchmarks, display table, and generate exports */
|
|
507
|
+
declare function matrixBenchExports(suite: MatrixSuite, args: DefaultCliArgs, reportOptions?: MatrixReportOptions, exportOptions?: MatrixExportOptions): Promise<void>;
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/export/JsonFormat.d.ts
|
|
510
|
+
/** Complete benchmark data structure for JSON export */
|
|
511
|
+
interface BenchmarkJsonData {
|
|
512
|
+
meta: {
|
|
513
|
+
timestamp: string;
|
|
514
|
+
version: string;
|
|
515
|
+
args: Record<string, any>;
|
|
516
|
+
environment: {
|
|
517
|
+
node: string;
|
|
518
|
+
platform: string;
|
|
519
|
+
arch?: string;
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
suites: BenchmarkSuite[];
|
|
523
|
+
}
|
|
524
|
+
interface BenchmarkSuite {
|
|
525
|
+
name: string;
|
|
526
|
+
groups: BenchmarkGroup[];
|
|
527
|
+
}
|
|
528
|
+
interface BenchmarkGroup {
|
|
529
|
+
name: string;
|
|
530
|
+
baseline?: BenchmarkResult;
|
|
531
|
+
benchmarks: BenchmarkResult[];
|
|
532
|
+
}
|
|
533
|
+
interface BenchmarkResult {
|
|
534
|
+
name: string;
|
|
535
|
+
status: "completed" | "running" | "failed";
|
|
536
|
+
/** Raw execution time samples in milliseconds */
|
|
537
|
+
samples: number[];
|
|
538
|
+
/** Statistical summaries */
|
|
539
|
+
time: {
|
|
540
|
+
min: number;
|
|
541
|
+
max: number;
|
|
542
|
+
mean: number;
|
|
543
|
+
p50: number;
|
|
544
|
+
p75: number;
|
|
545
|
+
p99: number;
|
|
546
|
+
p999: number;
|
|
547
|
+
};
|
|
548
|
+
/** Optional performance metrics */
|
|
549
|
+
heapSize?: {
|
|
550
|
+
min: number;
|
|
551
|
+
max: number;
|
|
552
|
+
mean: number;
|
|
553
|
+
};
|
|
554
|
+
gcTime?: {
|
|
555
|
+
min: number;
|
|
556
|
+
max: number;
|
|
557
|
+
mean: number;
|
|
558
|
+
};
|
|
559
|
+
cpu?: {
|
|
560
|
+
instructions?: number;
|
|
561
|
+
cycles?: number;
|
|
562
|
+
cacheMisses?: number;
|
|
563
|
+
branchMisses?: number;
|
|
564
|
+
};
|
|
565
|
+
/** Execution metadata */
|
|
566
|
+
execution: {
|
|
567
|
+
iterations: number;
|
|
568
|
+
totalTime: number;
|
|
569
|
+
warmupRuns?: number;
|
|
570
|
+
};
|
|
571
|
+
/** Adaptive mode results */
|
|
572
|
+
adaptive?: {
|
|
573
|
+
confidenceInterval: {
|
|
574
|
+
lower: number;
|
|
575
|
+
upper: number;
|
|
576
|
+
margin: number;
|
|
577
|
+
marginPercent: number;
|
|
578
|
+
confidence: number;
|
|
579
|
+
};
|
|
580
|
+
converged: boolean;
|
|
581
|
+
stopReason: "threshold_met" | "max_time" | "max_iterations";
|
|
582
|
+
};
|
|
583
|
+
/** Error information */
|
|
584
|
+
error?: {
|
|
585
|
+
message: string;
|
|
586
|
+
type: string;
|
|
587
|
+
stackTrace?: string;
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/export/PerfettoExport.d.ts
|
|
592
|
+
/** Export benchmark results to Perfetto-compatible trace file */
|
|
593
|
+
declare function exportPerfettoTrace(groups: ReportGroup[], outputPath: string, args: DefaultCliArgs): void;
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/HtmlDataPrep.d.ts
|
|
596
|
+
interface PrepareHtmlOptions {
|
|
597
|
+
cliArgs?: Record<string, unknown>;
|
|
598
|
+
sections?: ResultsMapper[];
|
|
599
|
+
currentVersion?: GitVersion;
|
|
600
|
+
baselineVersion?: GitVersion;
|
|
601
|
+
}
|
|
602
|
+
/** Prepare ReportData from benchmark results for HTML rendering */
|
|
603
|
+
declare function prepareHtmlData(groups: ReportGroup[], options: PrepareHtmlOptions): ReportData;
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/matrix/CaseLoader.d.ts
|
|
606
|
+
/** Module that exports case definitions */
|
|
607
|
+
interface CasesModule<T = unknown> {
|
|
608
|
+
cases: string[];
|
|
609
|
+
defaultCases?: string[];
|
|
610
|
+
defaultVariants?: string[];
|
|
611
|
+
loadCase?: (id: string) => LoadedCase<T> | Promise<LoadedCase<T>>;
|
|
612
|
+
}
|
|
613
|
+
/** Load a cases module by URL */
|
|
614
|
+
declare function loadCasesModule<T = unknown>(moduleUrl: string): Promise<CasesModule<T>>;
|
|
615
|
+
/** Load case data from a CasesModule or pass through the caseId */
|
|
616
|
+
declare function loadCaseData<T>(casesModule: CasesModule<T> | undefined, caseId: string): Promise<LoadedCase<T>>;
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/matrix/MatrixFilter.d.ts
|
|
619
|
+
/** Filter for matrix case/variant selection */
|
|
620
|
+
interface MatrixFilter {
|
|
621
|
+
case?: string;
|
|
622
|
+
variant?: string;
|
|
623
|
+
}
|
|
624
|
+
/** Parse filter string: "case/variant", "case/", "/variant", or "case" */
|
|
625
|
+
declare function parseMatrixFilter(filter: string): MatrixFilter;
|
|
626
|
+
/** Filtered matrix with explicit case and variant lists */
|
|
627
|
+
interface FilteredMatrix<T = unknown> extends BenchMatrix<T> {
|
|
628
|
+
filteredCases?: string[];
|
|
629
|
+
filteredVariants?: string[];
|
|
630
|
+
}
|
|
631
|
+
/** Apply filter to a matrix, merging with existing filters via intersection */
|
|
632
|
+
declare function filterMatrix<T>(matrix: FilteredMatrix<T>, filter?: MatrixFilter): Promise<FilteredMatrix<T>>;
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/StandardSections.d.ts
|
|
635
|
+
interface TimeStats {
|
|
636
|
+
mean?: number;
|
|
637
|
+
p50?: number;
|
|
638
|
+
p99?: number;
|
|
639
|
+
}
|
|
640
|
+
/** Section: mean, p50, p99 timing */
|
|
641
|
+
declare const timeSection: ResultsMapper<TimeStats>;
|
|
642
|
+
interface GcSectionStats {
|
|
643
|
+
gc?: number;
|
|
644
|
+
}
|
|
645
|
+
/** Section: GC time as fraction of total benchmark time (Node performance hooks) */
|
|
646
|
+
declare const gcSection: ResultsMapper<GcSectionStats>;
|
|
647
|
+
interface GcStatsInfo {
|
|
648
|
+
allocPerIter?: number;
|
|
649
|
+
collected?: number;
|
|
650
|
+
scavenges?: number;
|
|
651
|
+
fullGCs?: number;
|
|
652
|
+
promoPercent?: number;
|
|
653
|
+
pausePerIter?: number;
|
|
654
|
+
}
|
|
655
|
+
/** Section: detailed GC stats from --trace-gc-nvp (allocation, promotion, pauses) */
|
|
656
|
+
declare const gcStatsSection: ResultsMapper<GcStatsInfo>;
|
|
657
|
+
interface CpuStats {
|
|
658
|
+
cpuCacheMiss?: number;
|
|
659
|
+
cpuStall?: number;
|
|
660
|
+
}
|
|
661
|
+
/** Section: CPU L1 cache miss rate and stall rate (requires @mitata/counters) */
|
|
662
|
+
declare const cpuSection: ResultsMapper<CpuStats>;
|
|
663
|
+
interface RunStats {
|
|
664
|
+
runs?: number;
|
|
665
|
+
}
|
|
666
|
+
/** Section: number of sample iterations */
|
|
667
|
+
declare const runsSection: ResultsMapper<RunStats>;
|
|
668
|
+
/** Section: total sampling duration in seconds (brackets if >= 30s) */
|
|
669
|
+
declare const totalTimeSection: ResultsMapper<{
|
|
670
|
+
totalTime?: number;
|
|
671
|
+
}>;
|
|
672
|
+
interface AdaptiveStats {
|
|
673
|
+
median?: number;
|
|
674
|
+
mean?: number;
|
|
675
|
+
p99?: number;
|
|
676
|
+
convergence?: number;
|
|
677
|
+
}
|
|
678
|
+
/** Section: median, mean, p99, and convergence for adaptive mode */
|
|
679
|
+
declare const adaptiveSection: ResultsMapper<AdaptiveStats>;
|
|
680
|
+
/** Build generic sections based on CLI flags */
|
|
681
|
+
declare function buildGenericSections(args: {
|
|
682
|
+
"gc-stats"?: boolean;
|
|
683
|
+
"heap-sample"?: boolean;
|
|
684
|
+
}): ResultsMapper[];
|
|
685
|
+
interface OptStats {
|
|
686
|
+
tiers?: string;
|
|
687
|
+
deopt?: number;
|
|
688
|
+
}
|
|
689
|
+
/** Section: V8 optimization tier distribution and deopt count */
|
|
690
|
+
declare const optSection: ResultsMapper<OptStats>;
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/StatisticalUtils.d.ts
|
|
693
|
+
/** @return mean of values */
|
|
694
|
+
declare function average(values: number[]): number;
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/table-util/ConvergenceFormatters.d.ts
|
|
697
|
+
/** @return convergence percentage with color for low values */
|
|
698
|
+
declare function formatConvergence(v: unknown): string;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/table-util/Formatters.d.ts
|
|
701
|
+
/** Format time in milliseconds, showing very small values with units */
|
|
702
|
+
declare function timeMs(ms: unknown): string | null;
|
|
703
|
+
/** Format integer with thousand separators */
|
|
704
|
+
declare function integer(x: unknown): string | null;
|
|
705
|
+
/** Format bytes with appropriate units (B, KB, MB, GB) */
|
|
706
|
+
declare function formatBytes(bytes: unknown): string | null;
|
|
707
|
+
/** @return truncated string with ellipsis if over maxLen */
|
|
708
|
+
declare function truncate(str: string, maxLen?: number): string;
|
|
709
|
+
//#endregion
|
|
710
|
+
export { type AnyVariant, type BenchGroup, type BenchMatrix, type BenchSuite, BenchmarkGroup, BenchmarkJsonData, type BenchmarkReport, BenchmarkResult, type BenchmarkSpec, BenchmarkSuite, type CaseResult, type CasesModule, type Configure, type DefaultCliArgs, type ExportOptions, type ExtraColumn, type FilteredMatrix, type GitVersion, type HtmlReportOptions, type LoadedCase, type MatrixDefaults, type MatrixExportOptions, type MatrixFilter, type MatrixReportOptions, type MatrixResults, type MatrixSuite, type MeasuredResults, type PrepareHtmlOptions, type ReportColumnGroup, type ReportData, type ReportGroup, type ResultsMapper, type RunMatrixOptions, type RunnerOptions, type StatefulVariant, type UnknownRecord, type Variant, type VariantFn, type VariantResult, adaptiveSection, average, benchExports, buildGenericSections, cliToMatrixOptions, cpuSection, defaultCliArgs, defaultMatrixReport, defaultReport, exportPerfettoTrace, exportReports, filterMatrix, formatBytes, formatConvergence, formatDateWithTimezone, formatGitVersion, gcPauseColumn, gcSection, gcStatsColumns, gcStatsSection, generateHtmlReport, getBaselineVersion, getCurrentGitVersion, hasField, heapTotalColumn, integer, isStatefulVariant, loadCaseData, loadCasesModule, matrixBenchExports, matrixToReportGroups, optSection, parseBenchArgs, parseCliArgs, parseMatrixFilter, prepareHtmlData, printHeapReports, reportMatrixResults, reportOptStatus, reportResults, runBenchmarks, runDefaultBench, runDefaultMatrixBench, runMatrix, runMatrixSuite, runsSection, timeMs, timeSection, totalTimeSection, truncate };
|
|
711
|
+
//# sourceMappingURL=index.d.mts.map
|