benchforge 0.1.11 → 0.2.4

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.
Files changed (253) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +99 -294
  3. package/bin/benchforge +1 -2
  4. package/dist/AnalyzeArchive-8NCJhmhS.mjs +145 -0
  5. package/dist/AnalyzeArchive-8NCJhmhS.mjs.map +1 -0
  6. package/dist/BenchMatrix-BZVrBB_h.mjs +1050 -0
  7. package/dist/BenchMatrix-BZVrBB_h.mjs.map +1 -0
  8. package/dist/{BenchRunner-BzyUfiyB.d.mts → BenchRunner-DglX1NOn.d.mts} +119 -66
  9. package/dist/CoverageSampler-D5T9DRqe.mjs +27 -0
  10. package/dist/CoverageSampler-D5T9DRqe.mjs.map +1 -0
  11. package/dist/Formatters-BWj3d4sv.mjs +95 -0
  12. package/dist/Formatters-BWj3d4sv.mjs.map +1 -0
  13. package/dist/{HeapSampler-B8dtKHn1.mjs → HeapSampler-Dq-hpXem.mjs} +4 -4
  14. package/dist/HeapSampler-Dq-hpXem.mjs.map +1 -0
  15. package/dist/RunBenchCLI-C17DrJz8.mjs +3075 -0
  16. package/dist/RunBenchCLI-C17DrJz8.mjs.map +1 -0
  17. package/dist/StatisticalUtils-BD92crgM.mjs +255 -0
  18. package/dist/StatisticalUtils-BD92crgM.mjs.map +1 -0
  19. package/dist/TimeSampler-Ds8n7l2B.mjs +29 -0
  20. package/dist/TimeSampler-Ds8n7l2B.mjs.map +1 -0
  21. package/dist/ViewerServer-BJhdnxlN.mjs +639 -0
  22. package/dist/ViewerServer-BJhdnxlN.mjs.map +1 -0
  23. package/dist/ViewerServer-CuMNdNBz.mjs +2 -0
  24. package/dist/bin/benchforge.mjs +4 -5
  25. package/dist/bin/benchforge.mjs.map +1 -1
  26. package/dist/index.d.mts +711 -558
  27. package/dist/index.mjs +98 -3
  28. package/dist/index.mjs.map +1 -0
  29. package/dist/runners/WorkerScript.d.mts +12 -4
  30. package/dist/runners/WorkerScript.mjs +77 -105
  31. package/dist/runners/WorkerScript.mjs.map +1 -1
  32. package/dist/viewer/assets/CIPlot-BkOvMoMa.js +1 -0
  33. package/dist/viewer/assets/HistogramKde-CmSyUFY0.js +1 -0
  34. package/dist/viewer/assets/LegendUtils-BJpbn_jr.js +55 -0
  35. package/dist/viewer/assets/SampleTimeSeries-C4VBhXr3.js +1 -0
  36. package/dist/viewer/assets/index-Br9bp_cX.js +153 -0
  37. package/dist/viewer/assets/index-NzXXe_CC.css +1 -0
  38. package/dist/viewer/index.html +19 -0
  39. package/dist/viewer/speedscope/LICENSE +21 -0
  40. package/dist/viewer/speedscope/SourceCodePro-Regular.ttf-ILST5JV6.woff2 +0 -0
  41. package/dist/viewer/speedscope/favicon-16x16-V2DMIAZS.js +2 -0
  42. package/dist/viewer/speedscope/favicon-16x16-V2DMIAZS.js.map +7 -0
  43. package/dist/viewer/speedscope/favicon-16x16-VSI62OPJ.png +0 -0
  44. package/dist/viewer/speedscope/favicon-32x32-3EB2YCUY.png +0 -0
  45. package/dist/viewer/speedscope/favicon-32x32-THY3JDJL.js +2 -0
  46. package/dist/viewer/speedscope/favicon-32x32-THY3JDJL.js.map +7 -0
  47. package/dist/viewer/speedscope/favicon-FOKUP5Y5.ico +0 -0
  48. package/dist/viewer/speedscope/favicon-M34RF7BI.js +2 -0
  49. package/dist/viewer/speedscope/favicon-M34RF7BI.js.map +7 -0
  50. package/dist/viewer/speedscope/file-format-schema.json +274 -0
  51. package/dist/viewer/speedscope/index.html +19 -0
  52. package/dist/viewer/speedscope/jfrview_bg-BLJXNNQB.wasm +0 -0
  53. package/dist/viewer/speedscope/perf-vertx-stacks-01-collapsed-all-ZNUIGAJL.txt +199 -0
  54. package/dist/viewer/speedscope/release.txt +3 -0
  55. package/dist/viewer/speedscope/source-code-pro.LICENSE.md +93 -0
  56. package/dist/viewer/speedscope/speedscope-GHPHNKXC.css +2 -0
  57. package/dist/viewer/speedscope/speedscope-GHPHNKXC.css.map +7 -0
  58. package/dist/viewer/speedscope/speedscope-QZFMJ7VP.js +212 -0
  59. package/dist/viewer/speedscope/speedscope-QZFMJ7VP.js.map +7 -0
  60. package/package.json +52 -27
  61. package/src/bin/benchforge.ts +2 -2
  62. package/src/cli/AnalyzeArchive.ts +232 -0
  63. package/src/cli/BrowserBench.ts +322 -0
  64. package/src/cli/CliArgs.ts +164 -51
  65. package/src/cli/CliExport.ts +179 -0
  66. package/src/cli/CliOptions.ts +147 -0
  67. package/src/cli/CliReport.ts +197 -0
  68. package/src/cli/FilterBenchmarks.ts +18 -30
  69. package/src/cli/RunBenchCLI.ts +132 -866
  70. package/src/cli/SuiteRunner.ts +160 -0
  71. package/src/cli/ViewerServer.ts +282 -0
  72. package/src/export/AllocExport.ts +121 -0
  73. package/src/export/ArchiveExport.ts +146 -0
  74. package/src/export/ArchiveFormat.ts +50 -0
  75. package/src/export/CoverageExport.ts +148 -0
  76. package/src/export/EditorUri.ts +10 -0
  77. package/src/export/PerfettoExport.ts +64 -99
  78. package/src/export/SpeedscopeTypes.ts +98 -0
  79. package/src/export/TimeExport.ts +115 -0
  80. package/src/index.ts +86 -67
  81. package/src/matrix/BenchMatrix.ts +230 -0
  82. package/src/matrix/CaseLoader.ts +8 -6
  83. package/src/matrix/MatrixDirRunner.ts +153 -0
  84. package/src/matrix/MatrixFilter.ts +49 -47
  85. package/src/matrix/MatrixInlineRunner.ts +50 -0
  86. package/src/matrix/MatrixReport.ts +90 -250
  87. package/src/matrix/VariantLoader.ts +5 -5
  88. package/src/profiling/browser/BenchLoop.ts +51 -0
  89. package/src/profiling/browser/BrowserCDP.ts +133 -0
  90. package/src/profiling/browser/BrowserGcStats.ts +33 -0
  91. package/src/profiling/browser/BrowserProfiler.ts +160 -0
  92. package/src/profiling/browser/CdpClient.ts +82 -0
  93. package/src/profiling/browser/CdpPage.ts +138 -0
  94. package/src/profiling/browser/ChromeLauncher.ts +158 -0
  95. package/src/profiling/browser/ChromeTraceEvent.ts +28 -0
  96. package/src/profiling/browser/PageLoadMode.ts +61 -0
  97. package/src/profiling/node/CoverageSampler.ts +27 -0
  98. package/src/profiling/node/CoverageTypes.ts +23 -0
  99. package/src/profiling/node/HeapSampleReport.ts +261 -0
  100. package/src/{heap-sample → profiling/node}/HeapSampler.ts +1 -2
  101. package/src/{heap-sample → profiling/node}/ResolvedProfile.ts +18 -9
  102. package/src/profiling/node/TimeSampler.ts +57 -0
  103. package/src/report/BenchmarkReport.ts +146 -0
  104. package/src/report/Colors.ts +9 -0
  105. package/src/report/Formatters.ts +110 -0
  106. package/src/report/GcSections.ts +151 -0
  107. package/src/{GitUtils.ts → report/GitUtils.ts} +18 -19
  108. package/src/report/HtmlReport.ts +223 -0
  109. package/src/report/ParseStats.ts +73 -0
  110. package/src/report/StandardSections.ts +147 -0
  111. package/src/report/ViewerSections.ts +286 -0
  112. package/src/report/text/TableReport.ts +253 -0
  113. package/src/report/text/TextReport.ts +123 -0
  114. package/src/runners/AdaptiveWrapper.ts +116 -236
  115. package/src/runners/BenchRunner.ts +20 -15
  116. package/src/{Benchmark.ts → runners/BenchmarkSpec.ts} +5 -6
  117. package/src/runners/CreateRunner.ts +5 -7
  118. package/src/runners/GcStats.ts +47 -50
  119. package/src/{MeasuredResults.ts → runners/MeasuredResults.ts} +43 -37
  120. package/src/runners/MergeBatches.ts +123 -0
  121. package/src/{NodeGC.ts → runners/NodeGC.ts} +2 -3
  122. package/src/runners/RunnerOrchestrator.ts +127 -243
  123. package/src/runners/RunnerUtils.ts +75 -1
  124. package/src/runners/SampleStats.ts +100 -0
  125. package/src/runners/TimingRunner.ts +244 -0
  126. package/src/runners/TimingUtils.ts +3 -2
  127. package/src/runners/WorkerScript.ts +135 -151
  128. package/src/stats/BootstrapDifference.ts +282 -0
  129. package/src/{PermutationTest.ts → stats/PermutationTest.ts} +8 -17
  130. package/src/stats/StatisticalUtils.ts +445 -0
  131. package/src/{tests → test}/AdaptiveConvergence.test.ts +10 -10
  132. package/src/test/AdaptiveRunner.test.ts +39 -41
  133. package/src/{tests → test}/AdaptiveSampling.test.ts +9 -9
  134. package/src/test/AdaptiveStatistics.integration.ts +2 -2
  135. package/src/{tests → test}/BenchMatrix.test.ts +19 -16
  136. package/src/test/BenchmarkReport.test.ts +63 -13
  137. package/src/test/BrowserBench.e2e.test.ts +186 -17
  138. package/src/test/BrowserBench.test.ts +10 -5
  139. package/src/test/BuildTimeSection.test.ts +130 -0
  140. package/src/test/CapSamples.test.ts +82 -0
  141. package/src/test/CoverageExport.test.ts +115 -0
  142. package/src/test/CoverageSampler.test.ts +33 -0
  143. package/src/test/HeapAttribution.test.ts +14 -14
  144. package/src/{tests → test}/MatrixFilter.test.ts +1 -1
  145. package/src/{tests → test}/MatrixReport.test.ts +1 -1
  146. package/src/test/PermutationTest.test.ts +1 -1
  147. package/src/{tests → test}/RealDataValidation.test.ts +6 -6
  148. package/src/test/RunBenchCLI.test.ts +39 -38
  149. package/src/test/RunnerOrchestrator.test.ts +12 -12
  150. package/src/test/StatisticalUtils.test.ts +48 -12
  151. package/src/{table-util/test → test}/TableReport.test.ts +2 -2
  152. package/src/test/TestUtils.ts +12 -7
  153. package/src/test/TimeExport.test.ts +139 -0
  154. package/src/test/TimeSampler.test.ts +37 -0
  155. package/src/test/ViewerLive.e2e.test.ts +159 -0
  156. package/src/test/ViewerStatic.static.e2e.test.ts +137 -0
  157. package/src/{tests → test}/fixtures/baseline/impl.ts +1 -1
  158. package/src/{tests → test}/fixtures/bevy30-samples.ts +3 -1
  159. package/src/test/fixtures/cases/asyncCases.ts +9 -0
  160. package/src/{tests → test}/fixtures/cases/cases.ts +5 -2
  161. package/src/test/fixtures/cases/variants/product.ts +2 -0
  162. package/src/test/fixtures/cases/variants/sum.ts +2 -0
  163. package/src/test/fixtures/discover/fast.ts +1 -0
  164. package/src/{tests → test}/fixtures/discover/slow.ts +1 -1
  165. package/src/test/fixtures/invalid/bad.ts +1 -0
  166. package/src/test/fixtures/loader/fast.ts +1 -0
  167. package/src/{tests → test}/fixtures/loader/slow.ts +1 -1
  168. package/src/test/fixtures/loader/stateful.ts +2 -0
  169. package/src/test/fixtures/stateful/stateful.ts +2 -0
  170. package/src/test/fixtures/variants/extra.ts +1 -0
  171. package/src/test/fixtures/variants/impl.ts +1 -0
  172. package/src/test/fixtures/worker/fast.ts +1 -0
  173. package/src/{tests → test}/fixtures/worker/slow.ts +1 -1
  174. package/src/viewer/DateFormat.ts +30 -0
  175. package/src/viewer/Helpers.ts +23 -0
  176. package/src/viewer/LineData.ts +120 -0
  177. package/src/viewer/Providers.ts +191 -0
  178. package/src/viewer/ReportData.ts +123 -0
  179. package/src/viewer/State.ts +49 -0
  180. package/src/viewer/Theme.ts +15 -0
  181. package/src/viewer/components/App.tsx +73 -0
  182. package/src/viewer/components/DropZone.tsx +71 -0
  183. package/src/viewer/components/LazyPlot.ts +33 -0
  184. package/src/viewer/components/SamplesPanel.tsx +214 -0
  185. package/src/viewer/components/Shell.tsx +26 -0
  186. package/src/viewer/components/SourcePanel.tsx +216 -0
  187. package/src/viewer/components/SummaryPanel.tsx +332 -0
  188. package/src/viewer/components/TabBar.tsx +131 -0
  189. package/src/viewer/components/TabContent.tsx +46 -0
  190. package/src/viewer/components/ThemeToggle.tsx +50 -0
  191. package/src/viewer/index.html +20 -0
  192. package/src/viewer/main.tsx +4 -0
  193. package/src/viewer/plots/CIPlot.ts +313 -0
  194. package/src/{html/browser → viewer/plots}/HistogramKde.ts +33 -38
  195. package/src/viewer/plots/LegendUtils.ts +134 -0
  196. package/src/viewer/plots/PlotTypes.ts +85 -0
  197. package/src/viewer/plots/RenderPlots.ts +230 -0
  198. package/src/viewer/plots/SampleTimeSeries.ts +306 -0
  199. package/src/viewer/plots/SvgHelpers.ts +136 -0
  200. package/src/viewer/plots/TimeSeriesMarks.ts +319 -0
  201. package/src/viewer/report.css +427 -0
  202. package/src/viewer/shell.css +357 -0
  203. package/src/viewer/tsconfig.json +11 -0
  204. package/dist/BrowserHeapSampler-B6asLKWQ.mjs +0 -202
  205. package/dist/BrowserHeapSampler-B6asLKWQ.mjs.map +0 -1
  206. package/dist/GcStats-wX7Xyblu.mjs +0 -77
  207. package/dist/GcStats-wX7Xyblu.mjs.map +0 -1
  208. package/dist/HeapSampler-B8dtKHn1.mjs.map +0 -1
  209. package/dist/TimingUtils-DwOwkc8G.mjs +0 -597
  210. package/dist/TimingUtils-DwOwkc8G.mjs.map +0 -1
  211. package/dist/browser/index.js +0 -914
  212. package/dist/src-B-DDaCa9.mjs +0 -3108
  213. package/dist/src-B-DDaCa9.mjs.map +0 -1
  214. package/src/BenchMatrix.ts +0 -380
  215. package/src/BenchmarkReport.ts +0 -161
  216. package/src/HtmlDataPrep.ts +0 -148
  217. package/src/StandardSections.ts +0 -261
  218. package/src/StatisticalUtils.ts +0 -175
  219. package/src/TypeUtil.ts +0 -8
  220. package/src/browser/BrowserGcStats.ts +0 -44
  221. package/src/browser/BrowserHeapSampler.ts +0 -271
  222. package/src/export/JsonExport.ts +0 -103
  223. package/src/export/JsonFormat.ts +0 -91
  224. package/src/export/SpeedscopeExport.ts +0 -202
  225. package/src/heap-sample/HeapSampleReport.ts +0 -269
  226. package/src/html/HtmlReport.ts +0 -131
  227. package/src/html/HtmlTemplate.ts +0 -284
  228. package/src/html/Types.ts +0 -88
  229. package/src/html/browser/CIPlot.ts +0 -287
  230. package/src/html/browser/LegendUtils.ts +0 -163
  231. package/src/html/browser/RenderPlots.ts +0 -263
  232. package/src/html/browser/SampleTimeSeries.ts +0 -389
  233. package/src/html/browser/Types.ts +0 -96
  234. package/src/html/browser/index.ts +0 -1
  235. package/src/html/index.ts +0 -17
  236. package/src/runners/BasicRunner.ts +0 -364
  237. package/src/table-util/ConvergenceFormatters.ts +0 -19
  238. package/src/table-util/Formatters.ts +0 -157
  239. package/src/table-util/README.md +0 -70
  240. package/src/table-util/TableReport.ts +0 -293
  241. package/src/tests/fixtures/cases/asyncCases.ts +0 -7
  242. package/src/tests/fixtures/cases/variants/product.ts +0 -2
  243. package/src/tests/fixtures/cases/variants/sum.ts +0 -2
  244. package/src/tests/fixtures/discover/fast.ts +0 -1
  245. package/src/tests/fixtures/invalid/bad.ts +0 -1
  246. package/src/tests/fixtures/loader/fast.ts +0 -1
  247. package/src/tests/fixtures/loader/stateful.ts +0 -2
  248. package/src/tests/fixtures/stateful/stateful.ts +0 -2
  249. package/src/tests/fixtures/variants/extra.ts +0 -1
  250. package/src/tests/fixtures/variants/impl.ts +0 -1
  251. package/src/tests/fixtures/worker/fast.ts +0 -1
  252. /package/src/{table-util/test → test}/TableValueExtractor.test.ts +0 -0
  253. /package/src/{table-util/test → test}/TableValueExtractor.ts +0 -0
package/dist/index.d.mts CHANGED
@@ -1,248 +1,68 @@
1
- import { a as MeasuredResults, i as BenchmarkSpec, n as BenchGroup, o as HeapProfile, r as BenchSuite, t as RunnerOptions } from "./BenchRunner-BzyUfiyB.mjs";
2
- import { Alignment } from "table";
1
+ import { a as MeasuredResults, c as HeapProfile, i as BenchmarkSpec, n as BenchGroup, o as PausePoint, r as BenchSuite, t as RunnerOptions } from "./BenchRunner-DglX1NOn.mjs";
3
2
  import { Argv, InferredOptionTypes } from "yargs";
4
- import * as node_http0 from "node:http";
3
+ import { Alignment } from "table";
5
4
 
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
- /** Options for runMatrix */
63
- interface RunMatrixOptions {
64
- iterations?: number;
65
- maxTime?: number;
66
- warmup?: number;
67
- useWorker?: boolean;
68
- filteredCases?: string[];
69
- filteredVariants?: string[];
70
- collect?: boolean;
71
- cpuCounters?: boolean;
72
- traceOpt?: boolean;
73
- noSettle?: boolean;
74
- pauseFirst?: number;
75
- pauseInterval?: number;
76
- pauseDuration?: number;
77
- gcStats?: boolean;
78
- heapSample?: boolean;
79
- heapInterval?: number;
80
- heapDepth?: number;
81
- }
82
- /** @return true if variant is a StatefulVariant (has setup + run) */
83
- declare function isStatefulVariant<T, S>(v: Variant<T, S>): v is StatefulVariant<T, S>;
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
- /** Build formatted table with column groups and baselines */
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
5
  //#region src/cli/CliArgs.d.ts
140
6
  type Configure<T> = (yargs: Argv) => Argv<T>;
141
- /** CLI args type inferred from cliOptions, plus optional file positional */
7
+ /** CLI args type inferred from cliOptions, plus optional file positional. */
142
8
  type DefaultCliArgs = InferredOptionTypes<typeof cliOptions> & {
143
9
  file?: string;
144
10
  };
145
11
  declare const cliOptions: {
146
- readonly time: {
12
+ readonly duration: {
147
13
  readonly type: "number";
148
- readonly default: 0.642;
149
14
  readonly requiresArg: true;
150
- readonly describe: "test duration in seconds";
15
+ readonly describe: "duration per batch in seconds (default: 0.642)";
151
16
  };
152
- readonly cpu: {
153
- readonly type: "boolean";
154
- readonly default: false;
155
- readonly describe: "CPU counter measurements (requires root)";
156
- };
157
- readonly collect: {
158
- readonly type: "boolean";
159
- readonly default: false;
160
- readonly describe: "force GC after each iteration";
161
- };
162
- readonly "gc-stats": {
163
- readonly type: "boolean";
164
- readonly default: false;
165
- readonly describe: "collect GC statistics (Node: --trace-gc-nvp, browser: CDP tracing)";
17
+ readonly iterations: {
18
+ readonly type: "number";
19
+ readonly requiresArg: true;
20
+ readonly describe: "iterations per batch (page loads for page-load mode, inner loop for bench)";
166
21
  };
167
- readonly profile: {
168
- readonly type: "boolean";
169
- readonly default: false;
170
- readonly describe: "run once for profiling";
22
+ readonly warmup: {
23
+ readonly type: "number";
24
+ readonly default: 0;
25
+ readonly describe: "warmup iterations before measurement";
171
26
  };
172
27
  readonly filter: {
173
28
  readonly type: "string";
174
29
  readonly requiresArg: true;
175
- readonly describe: "filter benchmarks by regex or substring";
30
+ readonly describe: "filter by name/regex. Matrix: case/variant, case/, /variant";
176
31
  };
177
32
  readonly all: {
178
33
  readonly type: "boolean";
179
34
  readonly default: false;
180
35
  readonly describe: "run all cases (ignore defaultCases)";
181
36
  };
37
+ readonly list: {
38
+ readonly type: "boolean";
39
+ readonly default: false;
40
+ readonly describe: "list available benchmarks (or matrix cases/variants)";
41
+ };
182
42
  readonly worker: {
183
43
  readonly type: "boolean";
184
44
  readonly default: true;
185
45
  readonly describe: "run in worker process for isolation (default: true)";
186
46
  };
187
- readonly adaptive: {
188
- readonly type: "boolean";
189
- readonly default: false;
190
- readonly describe: "adaptive sampling (experimental)";
191
- };
192
- readonly "min-time": {
47
+ readonly batches: {
193
48
  readonly type: "number";
194
49
  readonly default: 1;
195
- readonly describe: "minimum time before adaptive convergence can stop";
196
- };
197
- readonly convergence: {
198
- readonly type: "number";
199
- readonly default: 95;
200
- readonly describe: "adaptive confidence threshold (0-100)";
201
- };
202
- readonly warmup: {
203
- readonly type: "number";
204
- readonly default: 0;
205
- readonly describe: "warmup iterations before measurement";
206
- };
207
- readonly html: {
208
- readonly type: "boolean";
209
- readonly default: false;
210
- readonly describe: "generate HTML report and open in browser";
211
- };
212
- readonly "export-html": {
213
- readonly type: "string";
214
- readonly requiresArg: true;
215
- readonly describe: "export HTML report to specified file";
216
- };
217
- readonly json: {
218
- readonly type: "string";
219
- readonly requiresArg: true;
220
- readonly describe: "export benchmark data to JSON file";
221
- };
222
- readonly "export-perfetto": {
223
- readonly type: "string";
224
- readonly requiresArg: true;
225
- readonly describe: "export Perfetto trace file (view at ui.perfetto.dev)";
50
+ readonly describe: "divide time into N batches, alternating baseline/current order";
226
51
  };
227
- readonly speedscope: {
52
+ readonly "warmup-batch": {
228
53
  readonly type: "boolean";
229
54
  readonly default: false;
230
- readonly describe: "open heap profile in speedscope (via npx)";
231
- };
232
- readonly "export-speedscope": {
233
- readonly type: "string";
234
- readonly requiresArg: true;
235
- readonly describe: "export heap profile as speedscope JSON";
55
+ readonly describe: "include first batch in results (normally dropped to avoid OS cache warmup)";
236
56
  };
237
- readonly "trace-opt": {
238
- readonly type: "boolean";
239
- readonly default: false;
240
- readonly describe: "trace V8 optimization tiers (requires --allow-natives-syntax)";
57
+ readonly "equiv-margin": {
58
+ readonly type: "number";
59
+ readonly default: 2;
60
+ readonly describe: "equivalence margin % for baseline comparison (0 to disable)";
241
61
  };
242
- readonly "skip-settle": {
62
+ readonly "no-batch-trim": {
243
63
  readonly type: "boolean";
244
64
  readonly default: false;
245
- readonly describe: "skip post-warmup settle time (see V8 optimization cold start)";
65
+ readonly describe: "disable Tukey trimming of outlier batches";
246
66
  };
247
67
  readonly "pause-first": {
248
68
  readonly type: "number";
@@ -258,71 +78,180 @@ declare const cliOptions: {
258
78
  readonly default: 100;
259
79
  readonly describe: "pause duration in ms for V8 optimization";
260
80
  };
261
- readonly batches: {
81
+ readonly "gc-stats": {
82
+ readonly type: "boolean";
83
+ readonly default: false;
84
+ readonly describe: "collect GC statistics (Node: --trace-gc-nvp, browser: CDP tracing)";
85
+ };
86
+ readonly "gc-force": {
87
+ readonly type: "boolean";
88
+ readonly default: false;
89
+ readonly describe: "force GC after each iteration";
90
+ };
91
+ readonly adaptive: {
92
+ readonly type: "boolean";
93
+ readonly default: false;
94
+ readonly describe: "adaptive sampling (experimental)";
95
+ };
96
+ readonly "min-time": {
262
97
  readonly type: "number";
263
98
  readonly default: 1;
264
- readonly describe: "divide time into N batches, alternating baseline/current order";
99
+ readonly describe: "minimum time before adaptive convergence can stop";
265
100
  };
266
- readonly iterations: {
101
+ readonly convergence: {
267
102
  readonly type: "number";
268
- readonly requiresArg: true;
269
- readonly describe: "exact number of iterations (overrides --time)";
103
+ readonly default: 95;
104
+ readonly describe: "adaptive confidence threshold (0-100)";
270
105
  };
271
- readonly "heap-sample": {
106
+ readonly alloc: {
272
107
  readonly type: "boolean";
273
108
  readonly default: false;
274
- readonly describe: "heap sampling allocation attribution (includes garbage)";
109
+ readonly describe: "allocation sampling attribution (includes garbage)";
275
110
  };
276
- readonly "heap-interval": {
111
+ readonly "alloc-interval": {
277
112
  readonly type: "number";
278
113
  readonly default: 32768;
279
- readonly describe: "heap sampling interval in bytes";
114
+ readonly describe: "allocation sampling interval in bytes";
280
115
  };
281
- readonly "heap-depth": {
116
+ readonly "alloc-depth": {
282
117
  readonly type: "number";
283
118
  readonly default: 64;
284
- readonly describe: "heap sampling stack depth";
119
+ readonly describe: "allocation sampling stack depth";
285
120
  };
286
- readonly "heap-rows": {
121
+ readonly "alloc-rows": {
287
122
  readonly type: "number";
288
123
  readonly default: 20;
289
124
  readonly describe: "top allocation sites to show";
290
125
  };
291
- readonly "heap-stack": {
126
+ readonly "alloc-stack": {
292
127
  readonly type: "number";
293
128
  readonly default: 3;
294
129
  readonly describe: "call stack depth to display";
295
130
  };
296
- readonly "heap-verbose": {
131
+ readonly "alloc-verbose": {
297
132
  readonly type: "boolean";
298
133
  readonly default: false;
299
134
  readonly describe: "verbose output with file:// paths and line numbers";
300
135
  };
301
- readonly "heap-raw": {
136
+ readonly "alloc-raw": {
302
137
  readonly type: "boolean";
303
138
  readonly default: false;
304
- readonly describe: "dump every raw heap sample (ordinal, size, stack)";
139
+ readonly describe: "dump every raw allocation sample (ordinal, size, stack)";
305
140
  };
306
- readonly "heap-user-only": {
141
+ readonly "alloc-user-only": {
307
142
  readonly type: "boolean";
308
143
  readonly default: false;
309
144
  readonly describe: "filter to user code only (hide node internals)";
310
145
  };
146
+ readonly profile: {
147
+ readonly type: "boolean";
148
+ readonly default: false;
149
+ readonly alias: "time-sample";
150
+ readonly describe: "V8 CPU time sampling profiler";
151
+ };
152
+ readonly "profile-interval": {
153
+ readonly type: "number";
154
+ readonly default: 1000;
155
+ readonly alias: "time-interval";
156
+ readonly describe: "CPU sampling interval in microseconds";
157
+ };
158
+ readonly "call-counts": {
159
+ readonly type: "boolean";
160
+ readonly default: false;
161
+ readonly describe: "collect per-function execution counts via V8 precise coverage";
162
+ };
163
+ readonly stats: {
164
+ readonly type: "string";
165
+ readonly default: "mean,p50,p99";
166
+ readonly describe: "timing columns: mean|median|min|max|p<N> (e.g. mean,p70,p99)";
167
+ };
168
+ readonly view: {
169
+ readonly type: "boolean";
170
+ readonly default: false;
171
+ readonly alias: "html";
172
+ readonly describe: "open viewer in browser";
173
+ };
174
+ readonly "view-serve": {
175
+ readonly type: "boolean";
176
+ readonly default: false;
177
+ readonly describe: "start viewer server without opening browser (reload an existing tab)";
178
+ };
179
+ readonly "export-perfetto": {
180
+ readonly type: "string";
181
+ readonly requiresArg: true;
182
+ readonly describe: "export Perfetto trace file (view at ui.perfetto.dev)";
183
+ };
184
+ readonly "export-profile": {
185
+ readonly type: "string";
186
+ readonly requiresArg: true;
187
+ readonly alias: "export-time";
188
+ readonly describe: "export CPU profile as .cpuprofile (V8/Chrome DevTools format)";
189
+ };
190
+ readonly archive: {
191
+ readonly type: "string";
192
+ readonly describe: "archive profile + sources to .benchforge file";
193
+ };
194
+ readonly editor: {
195
+ readonly type: "string";
196
+ readonly default: "vscode";
197
+ readonly describe: "editor for source links: vscode, cursor, or custom://scheme";
198
+ };
199
+ readonly inspect: {
200
+ readonly type: "boolean";
201
+ readonly default: false;
202
+ readonly describe: "run once for external profiler attach";
203
+ };
204
+ readonly "trace-opt": {
205
+ readonly type: "boolean";
206
+ readonly default: false;
207
+ readonly describe: "trace V8 optimization tiers (requires --allow-natives-syntax)";
208
+ };
209
+ readonly "pause-warmup": {
210
+ readonly type: "number";
211
+ readonly default: 0;
212
+ readonly requiresArg: true;
213
+ readonly describe: "post-warmup settle time in ms for V8 background compilation (0 to skip)";
214
+ };
311
215
  readonly url: {
312
216
  readonly type: "string";
313
217
  readonly requiresArg: true;
314
218
  readonly describe: "page URL for browser profiling (enables browser mode)";
315
219
  };
220
+ readonly "page-load": {
221
+ readonly type: "boolean";
222
+ readonly default: false;
223
+ readonly describe: "passive page-load profiling (no __bench needed)";
224
+ };
225
+ readonly "wait-for": {
226
+ readonly type: "string";
227
+ readonly requiresArg: true;
228
+ readonly describe: "page-load completion: CSS selector, JS expression, 'load', or 'domcontentloaded'";
229
+ };
316
230
  readonly headless: {
317
231
  readonly type: "boolean";
318
- readonly default: true;
319
- readonly describe: "run browser in headless mode";
232
+ readonly default: false;
233
+ readonly describe: "run browser in headless mode (default: headed)";
320
234
  };
321
235
  readonly timeout: {
322
236
  readonly type: "number";
323
237
  readonly default: 60;
324
238
  readonly describe: "browser page timeout in seconds";
325
239
  };
240
+ readonly chrome: {
241
+ readonly type: "string";
242
+ readonly requiresArg: true;
243
+ readonly describe: "Chrome binary path (default: auto-detect or CHROME_PATH)";
244
+ };
245
+ readonly "chrome-profile": {
246
+ readonly type: "string";
247
+ readonly requiresArg: true;
248
+ readonly describe: "Chrome user profile directory (default: temp profile)";
249
+ };
250
+ readonly "baseline-url": {
251
+ readonly type: "string";
252
+ readonly requiresArg: true;
253
+ readonly describe: "baseline URL for A/B comparison (fresh tab per batch)";
254
+ };
326
255
  readonly "chrome-args": {
327
256
  readonly type: "string";
328
257
  readonly array: true;
@@ -330,103 +259,131 @@ declare const cliOptions: {
330
259
  readonly describe: "extra Chromium flags";
331
260
  };
332
261
  };
333
- /** @return yargs with standard benchmark options */
334
- declare function defaultCliArgs(yargsInstance: Argv): Argv<DefaultCliArgs>;
335
- /** @return parsed command line arguments */
262
+ /** Parse command line arguments with optional custom yargs configuration. */
336
263
  declare function parseCliArgs<T = DefaultCliArgs>(args: string[], configure?: Configure<T>): T;
264
+ /** Configure yargs for browser benchmarking with url as a required positional. */
265
+ declare function browserCliArgs(yargsInstance: Argv): Argv<DefaultCliArgs>;
266
+ /** Configure yargs with standard benchmark options and file positional. */
267
+ declare function defaultCliArgs(yargsInstance: Argv): Argv<DefaultCliArgs>;
337
268
  //#endregion
338
- //#region src/html/Types.d.ts
339
- /** Data passed to the HTML report generator */
340
- interface ReportData {
341
- groups: GroupData[];
342
- metadata: {
343
- timestamp: string;
344
- bencherVersion: string;
345
- cliArgs?: Record<string, unknown>;
346
- gcTrackingEnabled?: boolean;
347
- currentVersion?: GitVersion;
348
- baselineVersion?: GitVersion;
349
- };
350
- }
351
- interface GroupData {
352
- name: string;
353
- baseline?: BenchmarkData;
354
- benchmarks: BenchmarkData[];
355
- }
356
- interface BenchmarkData {
357
- name: string;
358
- samples: number[];
359
- warmupSamples?: number[];
360
- allocationSamples?: number[];
361
- heapSamples?: number[];
362
- gcEvents?: GcEvent[];
363
- optSamples?: number[];
364
- pausePoints?: PausePoint[];
365
- stats: {
366
- min: number;
367
- max: number;
368
- avg: number;
369
- p50: number;
370
- p75: number;
371
- p99: number;
372
- p999: number;
373
- };
374
- heapSize?: {
375
- min: number;
376
- max: number;
377
- avg: number;
378
- };
379
- sectionStats?: FormattedStat[];
380
- comparisonCI?: DifferenceCI;
381
- }
382
- interface FormattedStat {
383
- label: string;
384
- value: string;
385
- groupTitle?: string;
386
- }
387
- interface GcEvent {
388
- offset: number;
389
- duration: number;
390
- }
391
- interface PausePoint {
392
- sampleIndex: number;
393
- durationMs: number;
394
- }
395
- interface GitVersion {
396
- hash: string;
397
- date: string;
398
- dirty?: boolean;
399
- }
400
- type CIDirection = "faster" | "slower" | "uncertain";
269
+ //#region src/stats/StatisticalUtils.d.ts
270
+ /** Whether CI was computed from block-level or sample-level resampling */
271
+ type CILevel = "block" | "sample";
272
+ /** Stat descriptor for multi-bootstrap: known stat kinds enable zero-alloc inner loops */
273
+ type StatKind = "mean" | "min" | "max" | {
274
+ percentile: number;
275
+ };
276
+ type CIDirection = "faster" | "slower" | "uncertain" | "equivalent";
277
+ /** Binned histogram for efficient transfer to browser */
401
278
  interface HistogramBin {
279
+ /** Bin center value */
402
280
  x: number;
403
281
  count: number;
404
282
  }
283
+ /**
284
+ * Bootstrap confidence interval for percentage difference between two sample medians.
285
+ * Used for baseline comparisons: negative percent means current is faster.
286
+ */
405
287
  interface DifferenceCI {
288
+ /** Observed percentage difference (current - baseline) / baseline */
406
289
  percent: number;
290
+ /** Confidence interval [lower, upper] in percent */
407
291
  ci: [number, number];
292
+ /** Whether the CI excludes zero: "faster", "slower", or "uncertain" */
408
293
  direction: CIDirection;
294
+ /** Bootstrap distribution histogram for visualization */
409
295
  histogram?: HistogramBin[];
296
+ /** Label for the CI plot title (e.g. "mean Δ%") */
297
+ label?: string;
298
+ /** Blocks trimmed per side [baseline, current] via Tukey fences */
299
+ trimmed?: [number, number];
300
+ /** Block-level (between-run) or sample-level (within-run) resampling */
301
+ ciLevel?: CILevel;
302
+ /** false when batch count is too low for reliable CI */
303
+ ciReliable?: boolean;
304
+ /** Original sample count before subsampling (set only when cap applied) */
305
+ subsampled?: number;
306
+ }
307
+ declare const maxBootstrapInput = 1e4;
308
+ /** Compute a statistic from samples by kind */
309
+ declare function computeStat(samples: number[], kind: StatKind): number;
310
+ /** @return true if the stat kind supports bootstrap CI (min/max don't) */
311
+ declare function isBootstrappable(kind: StatKind): boolean;
312
+ /** @return mean of values */
313
+ declare function average(values: number[]): number;
314
+ /** @return median (50th percentile) of values */
315
+ declare function median(values: number[]): number;
316
+ /** @return value at percentile p (0-1), using O(N) quickselect */
317
+ declare function percentile(values: number[], p: number): number;
318
+ //#endregion
319
+ //#region src/report/text/TableReport.d.ts
320
+ type AnyColumn<T> = Column<T> | DiffColumn<T>;
321
+ /** Table column with a value formatter (non-diff). */
322
+ interface Column<T> extends ColumnFormat<T> {
323
+ formatter?: (value: unknown) => string | null;
324
+ diffKey?: undefined;
410
325
  }
411
- interface HtmlReportOptions {
412
- openBrowser: boolean;
413
- outputPath?: string;
326
+ interface DiffColumn<T> extends ColumnFormat<T> {
327
+ diffFormatter?: (value: unknown, baseline: unknown) => string | null;
328
+ formatter?: undefined;
329
+ diffKey: keyof T;
414
330
  }
415
- interface HtmlReportResult {
416
- reportDir: string;
417
- server?: node_http0.Server;
418
- closeServer?: () => void;
331
+ interface ColumnFormat<T> {
332
+ key: keyof T;
333
+ title: string;
334
+ alignment?: Alignment;
335
+ width?: number;
419
336
  }
337
+ /** Build formatted table with column groups and baseline diffs. */
420
338
  //#endregion
421
- //#region src/html/HtmlReport.d.ts
422
- /** Generate HTML report from prepared data and optionally open in browser */
423
- declare function generateHtmlReport(data: ReportData, options: HtmlReportOptions): Promise<HtmlReportResult>;
424
- //#endregion
425
- //#region src/html/HtmlTemplate.d.ts
426
- /** Format ISO date as local time with UTC: "Jan 9, 2026, 3:45 PM (2026-01-09T23:45:00Z)" */
427
- declare function formatDateWithTimezone(isoDate: string): string;
339
+ //#region src/report/BenchmarkReport.d.ts
340
+ /** Options that affect baseline comparison statistics */
341
+ interface ComparisonOptions {
342
+ /** Equivalence margin in percent (0 to disable) */
343
+ equivMargin?: number;
344
+ /** Disable Tukey trimming of outlier batches */
345
+ noBatchTrim?: boolean;
346
+ }
347
+ /** Benchmark results with optional baseline for comparison */
348
+ interface ReportGroup {
349
+ name: string;
350
+ reports: BenchmarkReport[];
351
+ baseline?: BenchmarkReport;
352
+ }
353
+ /** Results from a single benchmark run */
354
+ interface BenchmarkReport {
355
+ name: string;
356
+ measuredResults: MeasuredResults;
357
+ metadata?: UnknownRecord;
358
+ }
359
+ /** A titled group of related columns (one per report section) */
360
+ interface ReportSection {
361
+ title: string;
362
+ columns: ReportColumn[];
363
+ }
364
+ /** A table column with optional comparison behavior */
365
+ type ReportColumn = AnyColumn<Record<string, unknown>> & {
366
+ /** 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) */
367
+ higherIsBetter?: boolean; /** Stat descriptor: framework computes value from samples via computeStat */
368
+ statKind?: StatKind; /** Accessor for non-sample data (e.g., run count, metadata fields) */
369
+ value?: (results: MeasuredResults, metadata?: UnknownRecord) => unknown; /** Convert a timing-domain value to display domain (e.g., ms to lines/sec) */
370
+ toDisplay?: (timingValue: number, metadata?: Record<string, unknown>) => number;
371
+ };
372
+ type UnknownRecord = Record<string, unknown>;
373
+ /** Compute column values for a section from results + metadata.
374
+ * statKind columns: computeStat(samples, kind), then toDisplay.
375
+ * value columns: call the accessor directly. */
376
+ declare function computeColumnValues(section: ReportSection, results: MeasuredResults, metadata?: UnknownRecord): UnknownRecord;
377
+ /** True if any result in the groups has the specified field with a defined value */
378
+ declare function hasField(groups: ReportGroup[], field: keyof MeasuredResults): boolean;
428
379
  //#endregion
429
- //#region src/GitUtils.d.ts
380
+ //#region src/report/GitUtils.d.ts
381
+ /** Git commit hash, date, and dirty status for version tracking */
382
+ interface GitVersion {
383
+ hash: string;
384
+ date: string;
385
+ dirty?: boolean;
386
+ }
430
387
  /** Get current git version info. For dirty repos, uses most recent modified file date. */
431
388
  declare function getCurrentGitVersion(): GitVersion | undefined;
432
389
  /** Read baseline version from .baseline-version file */
@@ -434,184 +391,243 @@ declare function getBaselineVersion(baselineDir?: string): GitVersion | undefine
434
391
  /** Format git version for display: "abc1234 (Jan 9, 2026, 3:45 PM)" or "abc1234*" if dirty */
435
392
  declare function formatGitVersion(version: GitVersion): string;
436
393
  //#endregion
437
- //#region src/heap-sample/HeapSampleReport.d.ts
438
- interface CallFrame {
439
- fn: string;
394
+ //#region src/cli/CliExport.d.ts
395
+ /** Options for exporting benchmark results to various formats */
396
+ interface ExportOptions {
397
+ results: ReportGroup[];
398
+ args: DefaultCliArgs;
399
+ sections?: ReportSection[];
400
+ currentVersion?: GitVersion;
401
+ baselineVersion?: GitVersion;
402
+ }
403
+ /** Export options for matrix benchmarks (results/args supplied by the matrix pipeline). */
404
+ interface MatrixExportOptions {
405
+ sections?: ReportSection[];
406
+ currentVersion?: GitVersion;
407
+ baselineVersion?: GitVersion;
408
+ }
409
+ /** Export reports (JSON, Perfetto, archive, viewer) based on CLI args. */
410
+ declare function exportReports(options: ExportOptions): Promise<void>;
411
+ //#endregion
412
+ //#region src/matrix/CaseLoader.d.ts
413
+ /** Module exporting case IDs and an optional loader for case data */
414
+ interface CasesModule<T = unknown> {
415
+ cases: string[];
416
+ /** Subset of cases for quick runs */
417
+ defaultCases?: string[];
418
+ /** Subset of variants for quick runs */
419
+ defaultVariants?: string[];
420
+ loadCase?: (id: string) => LoadedCase<T> | Promise<LoadedCase<T>>;
421
+ }
422
+ /** Import and validate a cases module, which must export a `cases` array */
423
+ declare function loadCasesModule<T = unknown>(moduleUrl: string): Promise<CasesModule<T>>;
424
+ /** Load case data from a CasesModule, or use the caseId as data if no module */
425
+ declare function loadCaseData<T>(casesModule: CasesModule<T> | undefined, caseId: string): Promise<LoadedCase<T>>;
426
+ //#endregion
427
+ //#region src/matrix/BenchMatrix.d.ts
428
+ /** Stateless variant - called each iteration with case data */
429
+ type VariantFn<T = unknown> = (caseData: T) => void;
430
+ /** Stateful variant - setup once, run many */
431
+ interface StatefulVariant<T = unknown, S = unknown> {
432
+ setup: (caseData: T) => S | Promise<S>;
433
+ run: (state: S) => void;
434
+ }
435
+ /** A variant is either a plain function or a stateful setup+run pair */
436
+ type Variant<T = unknown, S = unknown> = VariantFn<T> | StatefulVariant<T, S>;
437
+ /** Variant with any state type, allowing mixed variants in a matrix */
438
+ type AnyVariant<T = unknown> = VariantFn<T> | StatefulVariant<T, any>;
439
+ /** Case data and optional metadata returned by a cases module */
440
+ interface LoadedCase<T = unknown> {
441
+ data: T;
442
+ metadata?: Record<string, unknown>;
443
+ }
444
+ /** Default runner settings applied to all matrix benchmarks */
445
+ interface MatrixDefaults {
446
+ warmup?: number;
447
+ maxTime?: number;
448
+ iterations?: number;
449
+ }
450
+ /** Configuration for a cases x variants benchmark matrix */
451
+ interface BenchMatrix<T = unknown> {
452
+ name: string;
453
+ variantDir?: string;
454
+ variants?: Record<string, AnyVariant<T>>;
455
+ cases?: string[];
456
+ casesModule?: string;
457
+ baselineDir?: string;
458
+ baselineVariant?: string;
459
+ defaults?: MatrixDefaults;
460
+ }
461
+ /** Named collection of benchmark matrices */
462
+ interface MatrixSuite {
463
+ name: string;
464
+ matrices: BenchMatrix<any>[];
465
+ }
466
+ /** Results for a single variant across all cases */
467
+ interface VariantResult {
468
+ id: string;
469
+ cases: CaseResult[];
470
+ }
471
+ /** Results for a single (variant, case) pair */
472
+ interface CaseResult {
473
+ caseId: string;
474
+ measured: MeasuredResults;
475
+ metadata?: Record<string, unknown>;
476
+ baseline?: MeasuredResults;
477
+ deltaPercent?: number;
478
+ }
479
+ /** Aggregated results from running a benchmark matrix */
480
+ interface MatrixResults {
481
+ name: string;
482
+ variants: VariantResult[];
483
+ }
484
+ /** Options for {@link runMatrix} */
485
+ interface RunMatrixOptions {
486
+ /** Maximum iterations per benchmark */
487
+ iterations?: number;
488
+ /** Maximum time in ms per benchmark */
489
+ maxTime?: number;
490
+ /** Number of warmup iterations before measurement */
491
+ warmup?: number;
492
+ /** Use worker process isolation (default: true for variantDir) */
493
+ useWorker?: boolean;
494
+ /** Number of interleaved batches for baseline comparison */
495
+ batches?: number;
496
+ /** Include first batch in results (normally dropped for OS cache warmup) */
497
+ warmupBatch?: boolean;
498
+ /** Run only these cases (from --filter) */
499
+ filteredCases?: string[];
500
+ /** Run only these variants (from --filter) */
501
+ filteredVariants?: string[];
502
+ /** Force garbage collection between iterations */
503
+ gcForce?: boolean;
504
+ /** Track V8 optimization/deoptimization events */
505
+ traceOpt?: boolean;
506
+ /** Pause duration in ms before warmup begins */
507
+ pauseWarmup?: number;
508
+ /** Pause duration in ms before first measurement */
509
+ pauseFirst?: number;
510
+ /** Pause every N iterations during measurement */
511
+ pauseInterval?: number;
512
+ /** Duration of each pause in ms */
513
+ pauseDuration?: number;
514
+ /** Collect GC statistics via --trace-gc-nvp */
515
+ gcStats?: boolean;
516
+ /** Enable heap allocation profiling */
517
+ alloc?: boolean;
518
+ /** Heap sampling interval in bytes */
519
+ allocInterval?: number;
520
+ /** Maximum stack depth for allocation traces */
521
+ allocDepth?: number;
522
+ /** Enable CPU time profiling */
523
+ profile?: boolean;
524
+ /** CPU profiling sample interval in microseconds */
525
+ profileInterval?: number;
526
+ /** Track function call counts via V8 coverage */
527
+ callCounts?: boolean;
528
+ }
529
+ /** Run a BenchMatrix with inline variants or variantDir */
530
+ declare function runMatrix<T>(matrix: BenchMatrix<T>, options?: RunMatrixOptions): Promise<MatrixResults>;
531
+ /** Type guard for StatefulVariant */
532
+ declare function isStatefulVariant<T, S>(v: Variant<T, S>): v is StatefulVariant<T, S>;
533
+ //#endregion
534
+ //#region src/profiling/node/ResolvedProfile.d.ts
535
+ /** A call frame with display-ready 1-indexed source positions */
536
+ interface ResolvedFrame {
537
+ /** Function name, "(anonymous)" when empty */
538
+ name: string;
539
+ /** Script URL or file path, "" when unknown */
440
540
  url: string;
541
+ /** 1-indexed line number */
441
542
  line: number;
543
+ /** 1-indexed column number (undefined when unknown) */
442
544
  col?: number;
443
545
  }
444
- type UserCodeFilter = (site: CallFrame) => boolean;
546
+ //#endregion
547
+ //#region src/profiling/node/HeapSampleReport.d.ts
548
+ /** Predicate that returns true for user code (vs. runtime internals) */
549
+ type UserCodeFilter = (site: ResolvedFrame) => boolean;
550
+ /** Options for {@link formatHeapReport} */
445
551
  interface HeapReportOptions {
552
+ /** Max sites to display */
446
553
  topN: number;
554
+ /** Caller stack frames to show per site (default 3) */
447
555
  stackDepth?: number;
556
+ /** Multi-line format with file paths (default false) */
448
557
  verbose?: boolean;
558
+ /** Dump every raw sample */
449
559
  raw?: boolean;
560
+ /** Filter to user code only, hiding runtime internals */
450
561
  userOnly?: boolean;
562
+ /** Predicate for user vs internal code (default {@link isNodeUserCode}) */
451
563
  isUserCode?: UserCodeFilter;
564
+ /** Total bytes across all nodes (before filtering) */
452
565
  totalAll?: number;
566
+ /** Total bytes for user code only */
453
567
  totalUserCode?: number;
568
+ /** Number of samples taken */
454
569
  sampleCount?: number;
455
570
  }
456
571
  //#endregion
572
+ //#region src/cli/CliOptions.d.ts
573
+ /** Convert CLI args to matrix runner options. */
574
+ declare function cliToMatrixOptions(args: DefaultCliArgs): RunMatrixOptions;
575
+ //#endregion
457
576
  //#region src/matrix/MatrixReport.d.ts
458
- /** Custom column definition for extra computed metrics */
459
- interface ExtraColumn {
460
- key: string;
461
- title: string;
462
- groupTitle?: string;
463
- extract: (caseResult: CaseResult) => unknown;
464
- formatter?: (value: unknown) => string;
465
- }
466
- /** Options for matrix report generation */
577
+ /** Options for {@link reportMatrixResults} */
467
578
  interface MatrixReportOptions {
468
- extraColumns?: ExtraColumn[];
469
- sections?: ResultsMapper[];
579
+ /** ReportSection sections (default: [timeSection, runsSection]) */
580
+ sections?: ReportSection[];
581
+ /** Custom title for the variant column (default: "variant") */
470
582
  variantTitle?: string;
583
+ /** Comparison options (equivalence margin, batch trimming) */
584
+ comparison?: ComparisonOptions;
471
585
  }
472
- /** GC statistics columns - derived from gcStatsSection for consistency */
473
- declare const gcStatsColumns: ExtraColumn[];
474
- /** GC pause time column */
475
- declare const gcPauseColumn: ExtraColumn;
476
- /** Heap sampling total bytes column */
477
- declare const heapTotalColumn: ExtraColumn;
478
- /** Format matrix results as one table per case */
586
+ /** Format matrix results as text, with one table per case */
479
587
  declare function reportMatrixResults(results: MatrixResults, options?: MatrixReportOptions): string;
480
588
  //#endregion
481
- //#region src/cli/RunBenchCLI.d.ts
482
- interface ExportOptions {
483
- results: ReportGroup[];
484
- args: DefaultCliArgs;
485
- sections?: any[];
486
- suiteName?: string;
487
- currentVersion?: GitVersion;
488
- baselineVersion?: GitVersion;
489
- }
490
- interface MatrixExportOptions {
491
- sections?: any[];
492
- currentVersion?: GitVersion;
493
- baselineVersion?: GitVersion;
494
- }
495
- /** Parse CLI with custom configuration */
496
- declare function parseBenchArgs<T = DefaultCliArgs>(configureArgs?: Configure<T>): T & DefaultCliArgs;
497
- /** Run suite with CLI arguments */
498
- declare function runBenchmarks(suite: BenchSuite, args: DefaultCliArgs): Promise<ReportGroup[]>;
499
- /** Generate table with standard sections */
500
- declare function defaultReport(groups: ReportGroup[], args: DefaultCliArgs): string;
501
- /** Run benchmarks, display table, and optionally generate HTML report */
502
- declare function benchExports(suite: BenchSuite, args: DefaultCliArgs): Promise<void>;
503
- /** Print heap allocation reports for benchmarks with heap profiles */
504
- declare function printHeapReports(groups: ReportGroup[], options: HeapReportOptions): void;
505
- /** Run benchmarks and display table. Suite is optional with --url (browser mode). */
506
- declare function runDefaultBench(suite?: BenchSuite, configureArgs?: Configure<any>): Promise<void>;
507
- /** Log V8 optimization tier distribution and deoptimizations */
589
+ //#region src/cli/CliReport.d.ts
590
+ /** Options for defaultReport: custom sections replace the CLI-derived defaults. */
591
+ interface DefaultReportOptions {
592
+ sections?: ReportSection[];
593
+ }
594
+ /** Generate text report table with standard sections based on CLI args. */
595
+ declare function defaultReport(groups: ReportGroup[], args: DefaultCliArgs, opts?: DefaultReportOptions): string;
596
+ /** Log V8 optimization tier distribution and deoptimizations. */
508
597
  declare function reportOptStatus(groups: ReportGroup[]): void;
509
- /** @return true if any result has the specified field with a defined value */
510
- declare function hasField(results: ReportGroup[], field: keyof MeasuredResults): boolean;
511
- /** Export reports (HTML, JSON, Perfetto) based on CLI args */
512
- declare function exportReports(options: ExportOptions): Promise<void>;
513
- /** Run matrix suite with CLI arguments.
514
- * no options ==> defaultCases/defaultVariants, --filter ==> subset of defaults,
515
- * --all --filter ==> subset of all, --all ==> all cases/variants */
516
- declare function runMatrixSuite(suite: MatrixSuite, args: DefaultCliArgs): Promise<MatrixResults[]>;
517
- /** Convert CLI args to matrix run options */
518
- declare function cliToMatrixOptions(args: DefaultCliArgs): RunMatrixOptions;
519
- /** Generate report for matrix results. Uses same sections as regular benchmarks. */
598
+ /** Print heap allocation profiles for each benchmark in the report groups. */
599
+ declare function printHeapReports(groups: ReportGroup[], options: HeapReportOptions): void;
600
+ /** Format matrix benchmark results as text, applying default sections from CLI args. */
520
601
  declare function defaultMatrixReport(results: MatrixResults[], reportOptions?: MatrixReportOptions, args?: DefaultCliArgs): string;
521
- /** Run matrix suite with full CLI handling (parse, run, report, export) */
522
- declare function runDefaultMatrixBench(suite: MatrixSuite, configureArgs?: Configure<any>, reportOptions?: MatrixReportOptions): Promise<void>;
523
- /** Convert MatrixResults to ReportGroup[] for export compatibility */
602
+ /** Convert MatrixResults to ReportGroup[] for the standard export pipeline. */
524
603
  declare function matrixToReportGroups(results: MatrixResults[]): ReportGroup[];
525
- /** Run matrix benchmarks, display table, and generate exports */
526
- declare function matrixBenchExports(suite: MatrixSuite, args: DefaultCliArgs, reportOptions?: MatrixReportOptions, exportOptions?: MatrixExportOptions): Promise<void>;
527
604
  //#endregion
528
- //#region src/export/JsonFormat.d.ts
529
- /** Complete benchmark data structure for JSON export */
530
- interface BenchmarkJsonData {
531
- meta: {
532
- timestamp: string;
533
- version: string;
534
- args: Record<string, any>;
535
- environment: {
536
- node: string;
537
- platform: string;
538
- arch?: string;
539
- };
540
- };
541
- suites: BenchmarkSuite[];
542
- }
543
- interface BenchmarkSuite {
544
- name: string;
545
- groups: BenchmarkGroup[];
546
- }
547
- interface BenchmarkGroup {
548
- name: string;
549
- baseline?: BenchmarkResult;
550
- benchmarks: BenchmarkResult[];
551
- }
552
- interface BenchmarkResult {
553
- name: string;
554
- status: "completed" | "running" | "failed";
555
- /** Raw execution time samples in milliseconds */
556
- samples: number[];
557
- /** Statistical summaries */
558
- time: {
559
- min: number;
560
- max: number;
561
- mean: number;
562
- p50: number;
563
- p75: number;
564
- p99: number;
565
- p999: number;
566
- };
567
- /** Optional performance metrics */
568
- heapSize?: {
569
- min: number;
570
- max: number;
571
- mean: number;
572
- };
573
- gcTime?: {
574
- min: number;
575
- max: number;
576
- mean: number;
577
- };
578
- cpu?: {
579
- instructions?: number;
580
- cycles?: number;
581
- cacheMisses?: number;
582
- branchMisses?: number;
583
- };
584
- /** Execution metadata */
585
- execution: {
586
- iterations: number;
587
- totalTime: number;
588
- warmupRuns?: number;
589
- };
590
- /** Adaptive mode results */
591
- adaptive?: {
592
- confidenceInterval: {
593
- lower: number;
594
- upper: number;
595
- margin: number;
596
- marginPercent: number;
597
- confidence: number;
598
- };
599
- converged: boolean;
600
- stopReason: "threshold_met" | "max_time" | "max_iterations";
601
- };
602
- /** Error information */
603
- error?: {
604
- message: string;
605
- type: string;
606
- stackTrace?: string;
607
- };
608
- }
605
+ //#region src/cli/RunBenchCLI.d.ts
606
+ /** Options for running a BenchSuite: custom sections replace the CLI-derived defaults. */
607
+ interface BenchExportsOptions {
608
+ sections?: ReportSection[];
609
+ }
610
+ /** Top-level CLI dispatch: route to view, analyze, or default bench runner. */
611
+ declare function dispatchCli(): Promise<void>;
612
+ /** Run benchmarks and display results. Suite is optional with --url (browser mode). */
613
+ declare function runDefaultBench(suite?: BenchSuite, configureArgs?: Configure<any>, argv?: string[], opts?: BenchExportsOptions): Promise<void>;
614
+ /** Parse CLI args with optional custom yargs configuration. */
615
+ declare function parseBenchArgs<T = DefaultCliArgs>(configureArgs?: Configure<T>, argv?: string[]): T & DefaultCliArgs;
616
+ /** Run a BenchSuite and print results with standard reporting. */
617
+ declare function benchExports(suite: BenchSuite, args: DefaultCliArgs, opts?: BenchExportsOptions): Promise<void>;
618
+ /** Run matrix suite with full CLI handling (parse, run, report, export). */
619
+ declare function runDefaultMatrixBench(suite: MatrixSuite, configureArgs?: Configure<any>, reportOptions?: MatrixReportOptions): Promise<void>;
620
+ /** Run a matrix suite, print results, and handle exports. */
621
+ declare function matrixBenchExports(suite: MatrixSuite, args: DefaultCliArgs, reportOptions?: MatrixReportOptions, exportOptions?: MatrixExportOptions): Promise<void>;
622
+ /** Run matrix suite with CLI arguments. --filter narrows defaults, --all --filter narrows all. */
623
+ declare function runMatrixSuite(suite: MatrixSuite, args: DefaultCliArgs): Promise<MatrixResults[]>;
609
624
  //#endregion
610
- //#region src/export/PerfettoExport.d.ts
611
- /** Export benchmark results to Perfetto-compatible trace file */
612
- declare function exportPerfettoTrace(groups: ReportGroup[], outputPath: string, args: DefaultCliArgs): void;
625
+ //#region src/cli/SuiteRunner.d.ts
626
+ /** Run a benchmark suite with CLI arguments. */
627
+ declare function runBenchmarks(suite: BenchSuite, args: DefaultCliArgs): Promise<ReportGroup[]>;
613
628
  //#endregion
614
- //#region src/export/SpeedscopeExport.d.ts
629
+ //#region src/export/SpeedscopeTypes.d.ts
630
+ /** Shared speedscope file format types and frame interning utilities. */
615
631
  /** speedscope file format (https://www.speedscope.app/file-format-schema.json) */
616
632
  interface SpeedscopeFile {
617
633
  $schema: "https://www.speedscope.app/file-format-schema.json";
@@ -622,13 +638,17 @@ interface SpeedscopeFile {
622
638
  name?: string;
623
639
  exporter?: string;
624
640
  }
641
+ /** A single call frame with optional source location */
625
642
  interface SpeedscopeFrame {
626
643
  name: string;
627
644
  file?: string;
628
645
  line?: number;
629
646
  col?: number;
630
647
  }
631
- interface SpeedscopeProfile {
648
+ /** Union of heap and time profile shapes (unit differs) */
649
+ type SpeedscopeProfile = SpeedscopeHeapProfile | SpeedscopeTimeProfile;
650
+ /** Heap allocation profile weighted by bytes */
651
+ interface SpeedscopeHeapProfile {
632
652
  type: "sampled";
633
653
  name: string;
634
654
  unit: "bytes";
@@ -637,39 +657,185 @@ interface SpeedscopeProfile {
637
657
  samples: number[][];
638
658
  weights: number[];
639
659
  }
640
- /** Export heap profiles from benchmark results to speedscope JSON format.
641
- * Creates one speedscope profile per benchmark that has a heapProfile.
642
- * @returns resolved output path, or undefined if no profiles were found */
660
+ /** CPU time profile weighted by microseconds */
661
+ interface SpeedscopeTimeProfile {
662
+ type: "sampled";
663
+ name: string;
664
+ unit: "microseconds";
665
+ startValue: number;
666
+ endValue: number;
667
+ samples: number[][];
668
+ weights: number[];
669
+ }
670
+ //#endregion
671
+ //#region src/export/AllocExport.d.ts
672
+ /** Export heap profiles to speedscope JSON. Returns output path, or undefined if no profiles. */
643
673
  declare function exportSpeedscope(groups: ReportGroup[], outputPath: string): string | undefined;
644
- /** Export to a temp file and open in speedscope via npx */
645
- declare function exportAndLaunchSpeedscope(groups: ReportGroup[]): void;
646
- /** Launch speedscope viewer on a file via npx */
647
- declare function launchSpeedscope(filePath: string): void;
648
- /** Convert a single HeapProfile to speedscope format (for standalone use) */
674
+ /** Convert a single HeapProfile to speedscope format. */
649
675
  declare function heapProfileToSpeedscope(name: string, profile: HeapProfile): SpeedscopeFile;
676
+ /** Build SpeedscopeFile from report groups. Returns undefined if no profiles found. */
677
+ declare function buildSpeedscopeFile(groups: ReportGroup[]): SpeedscopeFile | undefined;
650
678
  //#endregion
651
- //#region src/HtmlDataPrep.d.ts
652
- interface PrepareHtmlOptions {
653
- cliArgs?: Record<string, unknown>;
654
- sections?: ResultsMapper[];
655
- currentVersion?: GitVersion;
656
- baselineVersion?: GitVersion;
679
+ //#region src/viewer/ReportData.d.ts
680
+ /** Top-level data structure for the HTML benchmark report. */
681
+ interface ReportData {
682
+ groups: BenchmarkGroup[];
683
+ metadata: {
684
+ timestamp: string;
685
+ bencherVersion: string;
686
+ cliArgs?: Record<string, unknown>;
687
+ cliDefaults?: Record<string, unknown>;
688
+ gcTrackingEnabled?: boolean;
689
+ currentVersion?: GitVersion;
690
+ baselineVersion?: GitVersion;
691
+ environment?: {
692
+ node: string;
693
+ platform: string;
694
+ arch: string;
695
+ };
696
+ };
697
+ }
698
+ /** A named group of benchmarks, optionally compared against a baseline. */
699
+ interface BenchmarkGroup {
700
+ name: string;
701
+ baseline?: BenchmarkEntry;
702
+ benchmarks: BenchmarkEntry[];
703
+ warnings?: string[];
704
+ }
705
+ /** One benchmark's raw data, statistics, and optional comparison results. */
706
+ interface BenchmarkEntry {
707
+ name: string;
708
+ samples: number[];
709
+ warmupSamples?: number[];
710
+ allocationSamples?: number[];
711
+ heapSamples?: number[];
712
+ gcEvents?: GcEvent[];
713
+ optSamples?: number[];
714
+ pausePoints?: PausePoint[];
715
+ batchOffsets?: number[];
716
+ stats: BenchmarkStats;
717
+ heapSize?: {
718
+ min: number;
719
+ max: number;
720
+ avg: number;
721
+ };
722
+ totalTime?: number;
723
+ sections?: ViewerSection[];
724
+ coverageSummary?: CoverageSummary;
725
+ heapSummary?: HeapSummary;
726
+ comparisonCI?: DifferenceCI;
727
+ }
728
+ /** Summary percentile statistics for a benchmark's samples. */
729
+ interface BenchmarkStats {
730
+ min: number;
731
+ max: number;
732
+ avg: number;
733
+ p50: number;
734
+ p75: number;
735
+ p99: number;
736
+ p999: number;
737
+ cv?: number;
738
+ mad?: number;
739
+ outlierRate?: number;
740
+ }
741
+ /** A section of related stats for the viewer (e.g., "Lines / Sec", "GC"). */
742
+ interface ViewerSection {
743
+ title: string;
744
+ tabLink?: string;
745
+ rows: ViewerRow[];
746
+ }
747
+ /** A stat row with per-run values and optional comparison CI. */
748
+ interface ViewerRow {
749
+ label: string;
750
+ entries: ViewerEntry[];
751
+ comparisonCI?: DifferenceCI;
752
+ shared?: boolean;
753
+ /** First comparable row with a statKind in the section. */
754
+ primary?: boolean;
755
+ }
756
+ /** A single run's value for a stat. */
757
+ interface ViewerEntry {
758
+ runName: string;
759
+ value: string;
760
+ bootstrapCI?: BootstrapCIData;
761
+ }
762
+ /** Bootstrap CI data for inline visualization. */
763
+ interface BootstrapCIData {
764
+ estimate: number;
765
+ ci: [number, number];
766
+ histogram: HistogramBin[];
767
+ /** Formatted CI bounds for display (e.g., ["0.12ms", "0.15ms"]) */
768
+ ciLabels?: [string, string];
769
+ /** Block-level (between-run) or sample-level (within-run) resampling */
770
+ ciLevel?: CILevel;
771
+ /** false when batch count is too low for reliable CI */
772
+ ciReliable?: boolean;
773
+ }
774
+ /** Summary of coverage/call-count data. */
775
+ interface CoverageSummary {
776
+ functionCount: number;
777
+ totalCalls: number;
778
+ }
779
+ /** Summary of heap allocation profile. */
780
+ interface HeapSummary {
781
+ totalBytes: number;
782
+ userBytes: number;
783
+ }
784
+ /** A garbage collection event with timing relative to the benchmark start. */
785
+ interface GcEvent {
786
+ offset: number;
787
+ duration: number;
657
788
  }
658
- /** Prepare ReportData from benchmark results for HTML rendering */
659
- declare function prepareHtmlData(groups: ReportGroup[], options: PrepareHtmlOptions): ReportData;
660
789
  //#endregion
661
- //#region src/matrix/CaseLoader.d.ts
662
- /** Module that exports case definitions */
663
- interface CasesModule<T = unknown> {
664
- cases: string[];
665
- defaultCases?: string[];
666
- defaultVariants?: string[];
667
- loadCase?: (id: string) => LoadedCase<T> | Promise<LoadedCase<T>>;
790
+ //#region src/export/CoverageExport.d.ts
791
+ /** Per-function execution count at a specific source line. */
792
+ interface LineCoverage {
793
+ /** 1-indexed line number of the function start */
794
+ startLine: number;
795
+ /** Function name (empty string for anonymous top-level) */
796
+ functionName: string;
797
+ /** Number of times the function was invoked */
798
+ count: number;
668
799
  }
669
- /** Load a cases module by URL */
670
- declare function loadCasesModule<T = unknown>(moduleUrl: string): Promise<CasesModule<T>>;
671
- /** Load case data from a CasesModule or pass through the caseId */
672
- declare function loadCaseData<T>(casesModule: CasesModule<T> | undefined, caseId: string): Promise<LoadedCase<T>>;
800
+ //#endregion
801
+ //#region src/export/ArchiveFormat.d.ts
802
+ interface BenchforgeArchive {
803
+ /** Archive format version. */
804
+ schema: number;
805
+ /** Heap allocation profile in Speedscope format. */
806
+ allocProfile?: SpeedscopeFile;
807
+ /** CPU time profile in Speedscope format. */
808
+ timeProfile?: SpeedscopeFile;
809
+ /** Per-line coverage data keyed by source URL. */
810
+ coverage?: Record<string, LineCoverage[]>;
811
+ /** Benchmark report with suite results and statistics. */
812
+ report?: ReportData;
813
+ /** Source file contents keyed by file URL. */
814
+ sources: Record<string, string>;
815
+ /** Archive creation metadata. */
816
+ metadata: ArchiveMetadata;
817
+ }
818
+ interface ArchiveMetadata {
819
+ /** ISO timestamp (colons/periods replaced with dashes for filename safety). */
820
+ timestamp: string;
821
+ /** Benchforge package version. */
822
+ benchforgeVersion: string;
823
+ }
824
+ //#endregion
825
+ //#region src/export/ArchiveExport.d.ts
826
+ interface ArchiveOptions {
827
+ groups: ReportGroup[];
828
+ reportData?: ReportData;
829
+ timeProfileData?: string;
830
+ coverageData?: string;
831
+ outputPath?: string;
832
+ }
833
+ /** Build a .benchforge archive file. Returns output path, or undefined if nothing to archive. */
834
+ declare function archiveBenchmark(options: ArchiveOptions): Promise<string | undefined>;
835
+ //#endregion
836
+ //#region src/export/PerfettoExport.d.ts
837
+ /** Export benchmark results to Perfetto-compatible trace file */
838
+ declare function exportPerfettoTrace(groups: ReportGroup[], outputPath: string, args: DefaultCliArgs): void;
673
839
  //#endregion
674
840
  //#region src/matrix/MatrixFilter.d.ts
675
841
  /** Filter for matrix case/variant selection */
@@ -687,84 +853,71 @@ declare function parseMatrixFilter(filter: string): MatrixFilter;
687
853
  /** Apply filter to a matrix, merging with existing filters via intersection */
688
854
  declare function filterMatrix<T>(matrix: FilteredMatrix<T>, filter?: MatrixFilter): Promise<FilteredMatrix<T>>;
689
855
  //#endregion
690
- //#region src/StandardSections.d.ts
691
- interface TimeStats {
692
- mean?: number;
693
- p50?: number;
694
- p99?: number;
695
- }
696
- interface GcSectionStats {
697
- gc?: number;
698
- }
699
- interface GcStatsInfo {
700
- allocPerIter?: number;
701
- collected?: number;
702
- scavenges?: number;
703
- fullGCs?: number;
704
- promoPercent?: number;
705
- pausePerIter?: number;
706
- }
707
- interface CpuStats {
708
- cpuCacheMiss?: number;
709
- cpuStall?: number;
710
- }
711
- interface RunStats {
712
- runs?: number;
713
- }
714
- interface AdaptiveStats {
715
- median?: number;
716
- mean?: number;
717
- p99?: number;
718
- convergence?: number;
719
- }
720
- interface OptStats {
721
- tiers?: string;
722
- deopt?: number;
723
- }
724
- /** Section: mean, p50, p99 timing */
725
- declare const timeSection: ResultsMapper<TimeStats>;
726
- /** Section: GC time as fraction of total benchmark time (Node performance hooks) */
727
- declare const gcSection: ResultsMapper<GcSectionStats>;
728
- /** Section: detailed GC stats from --trace-gc-nvp (allocation, promotion, pauses) */
729
- declare const gcStatsSection: ResultsMapper<GcStatsInfo>;
730
- /** Section: CPU L1 cache miss rate and stall rate (requires @mitata/counters) */
731
- declare const cpuSection: ResultsMapper<CpuStats>;
732
- /** Section: number of sample iterations */
733
- declare const runsSection: ResultsMapper<RunStats>;
734
- /** Section: total sampling duration in seconds (brackets if >= 30s) */
735
- declare const totalTimeSection: ResultsMapper<{
736
- totalTime?: number;
737
- }>;
738
- /** Section: median, mean, p99, and convergence for adaptive mode */
739
- declare const adaptiveSection: ResultsMapper<AdaptiveStats>;
740
- /** Section: V8 optimization tier distribution and deopt count */
741
- declare const optSection: ResultsMapper<OptStats>;
742
- /** Build generic sections based on CLI flags */
743
- declare function buildGenericSections(args: {
744
- "gc-stats"?: boolean;
745
- "heap-sample"?: boolean;
746
- }): ResultsMapper[];
747
- //#endregion
748
- //#region src/StatisticalUtils.d.ts
749
- /** @return mean of values */
750
- declare function average(values: number[]): number;
751
- //#endregion
752
- //#region src/table-util/ConvergenceFormatters.d.ts
753
- /** @return convergence percentage with color for low values */
754
- declare function formatConvergence(v: unknown): string;
755
- //#endregion
756
- //#region src/table-util/Formatters.d.ts
757
- /** Format time in milliseconds, showing very small values with units */
856
+ //#region src/report/Formatters.d.ts
857
+ /** Format time in milliseconds with appropriate units */
758
858
  declare function timeMs(ms: unknown): string | null;
759
859
  /** Format integer with thousand separators */
760
860
  declare function integer(x: unknown): string | null;
761
- /** Format bytes with appropriate units (B, KB, MB, GB).
762
- * Use `space: true` for human-readable console output (`1.5 KB`). */
861
+ /** Format bytes with appropriate units. Use `space: true` for `1.5 KB` style. */
763
862
  declare function formatBytes(bytes: unknown, opts?: {
764
863
  space?: boolean;
765
864
  }): string | null;
766
865
  /** @return truncated string with ellipsis if over maxLen */
767
866
  declare function truncate(str: string, maxLen?: number): string;
867
+ /** @return convergence percentage with color for low values */
868
+ declare function formatConvergence(v: unknown): string;
869
+ //#endregion
870
+ //#region src/report/GcSections.d.ts
871
+ /** Report section: GC time as fraction of total benchmark time. */
872
+ declare const gcSection: ReportSection;
873
+ /** Report section: detailed GC stats from --trace-gc-nvp. */
874
+ declare const gcStatsSection: ReportSection;
875
+ /** @return GC stats sections if enabled by CLI flags */
876
+ declare function gcSections(args: {
877
+ "gc-stats"?: boolean;
878
+ }): ReportSection[];
879
+ //#endregion
880
+ //#region src/report/HtmlReport.d.ts
881
+ /** Options for prepareHtmlData: report sections, git versions, and CLI args */
882
+ interface PrepareHtmlOptions extends ComparisonOptions {
883
+ cliArgs?: Record<string, unknown>;
884
+ sections?: ReportSection[];
885
+ currentVersion?: GitVersion;
886
+ baselineVersion?: GitVersion;
887
+ }
888
+ /** Convert benchmark results into a ReportData payload for the HTML viewer */
889
+ declare function prepareHtmlData(groups: ReportGroup[], options: PrepareHtmlOptions): ReportData;
890
+ //#endregion
891
+ //#region src/report/StandardSections.d.ts
892
+ /** Default timing section: mean, p50, p99. */
893
+ declare const timeSection: ReportSection;
894
+ /** Report section: number of sample iterations. */
895
+ declare const runsSection: ReportSection;
896
+ /** Report section: total sampling duration. */
897
+ declare const totalTimeSection: ReportSection;
898
+ /** Report sections: timing stats and convergence for adaptive mode. */
899
+ declare const adaptiveSections: ReportSection[];
900
+ /** Report section: V8 optimization tier distribution and deopt count. */
901
+ declare const optSection: ReportSection;
902
+ /** Build a time section with user-chosen percentile/stat columns. */
903
+ declare function buildTimeSection(stats?: string): ReportSection;
904
+ /** @return default report sections from CLI flags (GC stats if enabled, plus run count). */
905
+ declare function buildGenericSections(args: {
906
+ "gc-stats"?: boolean;
907
+ alloc?: boolean;
908
+ }): ReportSection[];
909
+ //#endregion
910
+ //#region src/report/text/TextReport.d.ts
911
+ /** Options for text report rendering, including baseline comparison settings. */
912
+ interface TextReportOptions extends ComparisonOptions {}
913
+ /** Build a formatted text table from benchmark groups, with baseline diff columns when present. */
914
+ declare function reportResults(groups: ReportGroup[], sections: ReportSection[], options?: TextReportOptions): string;
915
+ //#endregion
916
+ //#region src/viewer/DateFormat.d.ts
917
+ /** Format ISO date as local time with UTC: "Jan 9, 2026, 3:45 PM (2026-01-09T23:45:00Z)" */
918
+ declare function formatDateWithTimezone(isoDate: string): string;
919
+ /** Format relative time: "5m ago", "2h ago", "yesterday", "3 days ago" */
920
+ declare function formatRelativeTime(isoDate: string): string;
768
921
  //#endregion
769
- 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, exportAndLaunchSpeedscope, exportPerfettoTrace, exportReports, exportSpeedscope, filterMatrix, formatBytes, formatConvergence, formatDateWithTimezone, formatGitVersion, gcPauseColumn, gcSection, gcStatsColumns, gcStatsSection, generateHtmlReport, getBaselineVersion, getCurrentGitVersion, hasField, heapProfileToSpeedscope, heapTotalColumn, integer, isStatefulVariant, launchSpeedscope, loadCaseData, loadCasesModule, matrixBenchExports, matrixToReportGroups, optSection, parseBenchArgs, parseCliArgs, parseMatrixFilter, prepareHtmlData, printHeapReports, reportMatrixResults, reportOptStatus, reportResults, runBenchmarks, runDefaultBench, runDefaultMatrixBench, runMatrix, runMatrixSuite, runsSection, timeMs, timeSection, totalTimeSection, truncate };
922
+ export { type AnyVariant, type ArchiveMetadata, type BenchGroup, type BenchMatrix, type BenchSuite, type BenchforgeArchive, type BenchmarkReport, type BenchmarkSpec, type CaseResult, type CasesModule, type ComparisonOptions, type Configure, type DefaultCliArgs, type ExportOptions, type FilteredMatrix, type GitVersion, type LoadedCase, type MatrixDefaults, type MatrixExportOptions, type MatrixFilter, type MatrixReportOptions, type MatrixResults, type MatrixSuite, type MeasuredResults, type PrepareHtmlOptions, type ReportColumn, type ReportData, type ReportGroup, type ReportSection, type RunMatrixOptions, type RunnerOptions, type StatKind, type StatefulVariant, type UnknownRecord, type Variant, type VariantFn, type VariantResult, adaptiveSections, archiveBenchmark, average, benchExports, browserCliArgs, buildGenericSections, buildSpeedscopeFile, buildTimeSection, cliToMatrixOptions, computeColumnValues, computeStat, defaultCliArgs, defaultMatrixReport, defaultReport, dispatchCli, exportPerfettoTrace, exportReports, exportSpeedscope, filterMatrix, formatBytes, formatConvergence, formatDateWithTimezone, formatGitVersion, formatRelativeTime, gcSection, gcSections, gcStatsSection, getBaselineVersion, getCurrentGitVersion, hasField, heapProfileToSpeedscope, integer, isBootstrappable, isStatefulVariant, loadCaseData, loadCasesModule, matrixBenchExports, matrixToReportGroups, maxBootstrapInput, median, optSection, parseBenchArgs, parseCliArgs, parseMatrixFilter, percentile, prepareHtmlData, printHeapReports, reportMatrixResults, reportOptStatus, reportResults, runBenchmarks, runDefaultBench, runDefaultMatrixBench, runMatrix, runMatrixSuite, runsSection, timeMs, timeSection, totalTimeSection, truncate };
770
923
  //# sourceMappingURL=index.d.mts.map