benchforge 0.1.9 → 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 -260
  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-DglX1NOn.d.mts +302 -0
  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 +731 -522
  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 +92 -120
  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 -26
  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 -48
  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 +138 -844
  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 +91 -126
  78. package/src/export/SpeedscopeTypes.ts +98 -0
  79. package/src/export/TimeExport.ts +115 -0
  80. package/src/index.ts +87 -62
  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 +55 -53
  85. package/src/matrix/MatrixInlineRunner.ts +50 -0
  86. package/src/matrix/MatrixReport.ts +94 -254
  87. package/src/matrix/VariantLoader.ts +9 -9
  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 +55 -13
  101. package/src/profiling/node/ResolvedProfile.ts +98 -0
  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 +167 -287
  115. package/src/runners/BenchRunner.ts +27 -22
  116. package/src/{Benchmark.ts → runners/BenchmarkSpec.ts} +5 -6
  117. package/src/runners/CreateRunner.ts +5 -7
  118. package/src/runners/GcStats.ts +58 -61
  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 +180 -296
  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 +162 -178
  128. package/src/stats/BootstrapDifference.ts +282 -0
  129. package/src/{PermutationTest.ts → stats/PermutationTest.ts} +31 -40
  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 +9 -41
  135. package/src/{tests → test}/BenchMatrix.test.ts +31 -28
  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 +51 -0
  144. package/src/{tests → test}/MatrixFilter.test.ts +16 -16
  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 +57 -56
  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 +35 -30
  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 +42 -47
  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/BenchRunner-CSKN9zPy.d.mts +0 -225
  205. package/dist/BrowserHeapSampler-DCeL42RE.mjs +0 -202
  206. package/dist/BrowserHeapSampler-DCeL42RE.mjs.map +0 -1
  207. package/dist/GcStats-ByEovUi1.mjs +0 -77
  208. package/dist/GcStats-ByEovUi1.mjs.map +0 -1
  209. package/dist/HeapSampler-B8dtKHn1.mjs.map +0 -1
  210. package/dist/TimingUtils-ClclVQ7E.mjs +0 -597
  211. package/dist/TimingUtils-ClclVQ7E.mjs.map +0 -1
  212. package/dist/browser/index.js +0 -914
  213. package/dist/src-Cf_LXwlp.mjs +0 -2873
  214. package/dist/src-Cf_LXwlp.mjs.map +0 -1
  215. package/src/BenchMatrix.ts +0 -380
  216. package/src/BenchmarkReport.ts +0 -156
  217. package/src/HtmlDataPrep.ts +0 -148
  218. package/src/StandardSections.ts +0 -261
  219. package/src/StatisticalUtils.ts +0 -176
  220. package/src/TypeUtil.ts +0 -8
  221. package/src/browser/BrowserGcStats.ts +0 -44
  222. package/src/browser/BrowserHeapSampler.ts +0 -271
  223. package/src/export/JsonExport.ts +0 -103
  224. package/src/export/JsonFormat.ts +0 -91
  225. package/src/heap-sample/HeapSampleReport.ts +0 -196
  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 -152
  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 +9 -9
package/dist/index.d.mts CHANGED
@@ -1,238 +1,68 @@
1
- import { a as MeasuredResults, i as BenchmarkSpec, n as BenchGroup, r as BenchSuite, t as RunnerOptions } from "./BenchRunner-CSKN9zPy.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
- /** @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
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";
50
+ readonly describe: "divide time into N batches, alternating baseline/current order";
206
51
  };
207
- readonly html: {
52
+ readonly "warmup-batch": {
208
53
  readonly type: "boolean";
209
54
  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 perfetto: {
223
- readonly type: "string";
224
- readonly requiresArg: true;
225
- readonly describe: "export Perfetto trace file (view at ui.perfetto.dev)";
55
+ readonly describe: "include first batch in results (normally dropped to avoid OS cache warmup)";
226
56
  };
227
- readonly "trace-opt": {
228
- readonly type: "boolean";
229
- readonly default: false;
230
- 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)";
231
61
  };
232
- readonly "skip-settle": {
62
+ readonly "no-batch-trim": {
233
63
  readonly type: "boolean";
234
64
  readonly default: false;
235
- readonly describe: "skip post-warmup settle time (see V8 optimization cold start)";
65
+ readonly describe: "disable Tukey trimming of outlier batches";
236
66
  };
237
67
  readonly "pause-first": {
238
68
  readonly type: "number";
@@ -248,66 +78,180 @@ declare const cliOptions: {
248
78
  readonly default: 100;
249
79
  readonly describe: "pause duration in ms for V8 optimization";
250
80
  };
251
- 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": {
252
97
  readonly type: "number";
253
98
  readonly default: 1;
254
- readonly describe: "divide time into N batches, alternating baseline/current order";
99
+ readonly describe: "minimum time before adaptive convergence can stop";
255
100
  };
256
- readonly iterations: {
101
+ readonly convergence: {
257
102
  readonly type: "number";
258
- readonly requiresArg: true;
259
- readonly describe: "exact number of iterations (overrides --time)";
103
+ readonly default: 95;
104
+ readonly describe: "adaptive confidence threshold (0-100)";
260
105
  };
261
- readonly "heap-sample": {
106
+ readonly alloc: {
262
107
  readonly type: "boolean";
263
108
  readonly default: false;
264
- readonly describe: "heap sampling allocation attribution (includes garbage)";
109
+ readonly describe: "allocation sampling attribution (includes garbage)";
265
110
  };
266
- readonly "heap-interval": {
111
+ readonly "alloc-interval": {
267
112
  readonly type: "number";
268
113
  readonly default: 32768;
269
- readonly describe: "heap sampling interval in bytes";
114
+ readonly describe: "allocation sampling interval in bytes";
270
115
  };
271
- readonly "heap-depth": {
116
+ readonly "alloc-depth": {
272
117
  readonly type: "number";
273
118
  readonly default: 64;
274
- readonly describe: "heap sampling stack depth";
119
+ readonly describe: "allocation sampling stack depth";
275
120
  };
276
- readonly "heap-rows": {
121
+ readonly "alloc-rows": {
277
122
  readonly type: "number";
278
123
  readonly default: 20;
279
124
  readonly describe: "top allocation sites to show";
280
125
  };
281
- readonly "heap-stack": {
126
+ readonly "alloc-stack": {
282
127
  readonly type: "number";
283
128
  readonly default: 3;
284
129
  readonly describe: "call stack depth to display";
285
130
  };
286
- readonly "heap-verbose": {
131
+ readonly "alloc-verbose": {
287
132
  readonly type: "boolean";
288
133
  readonly default: false;
289
134
  readonly describe: "verbose output with file:// paths and line numbers";
290
135
  };
291
- readonly "heap-user-only": {
136
+ readonly "alloc-raw": {
137
+ readonly type: "boolean";
138
+ readonly default: false;
139
+ readonly describe: "dump every raw allocation sample (ordinal, size, stack)";
140
+ };
141
+ readonly "alloc-user-only": {
292
142
  readonly type: "boolean";
293
143
  readonly default: false;
294
144
  readonly describe: "filter to user code only (hide node internals)";
295
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
+ };
296
215
  readonly url: {
297
216
  readonly type: "string";
298
217
  readonly requiresArg: true;
299
218
  readonly describe: "page URL for browser profiling (enables browser mode)";
300
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
+ };
301
230
  readonly headless: {
302
231
  readonly type: "boolean";
303
- readonly default: true;
304
- readonly describe: "run browser in headless mode";
232
+ readonly default: false;
233
+ readonly describe: "run browser in headless mode (default: headed)";
305
234
  };
306
235
  readonly timeout: {
307
236
  readonly type: "number";
308
237
  readonly default: 60;
309
238
  readonly describe: "browser page timeout in seconds";
310
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
+ };
311
255
  readonly "chrome-args": {
312
256
  readonly type: "string";
313
257
  readonly array: true;
@@ -315,103 +259,131 @@ declare const cliOptions: {
315
259
  readonly describe: "extra Chromium flags";
316
260
  };
317
261
  };
318
- /** @return yargs with standard benchmark options */
319
- declare function defaultCliArgs(yargsInstance: Argv): Argv<DefaultCliArgs>;
320
- /** @return parsed command line arguments */
262
+ /** Parse command line arguments with optional custom yargs configuration. */
321
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>;
322
268
  //#endregion
323
- //#region src/html/Types.d.ts
324
- /** Data passed to the HTML report generator */
325
- interface ReportData {
326
- groups: GroupData[];
327
- metadata: {
328
- timestamp: string;
329
- bencherVersion: string;
330
- cliArgs?: Record<string, unknown>;
331
- gcTrackingEnabled?: boolean;
332
- currentVersion?: GitVersion;
333
- baselineVersion?: GitVersion;
334
- };
335
- }
336
- interface GroupData {
337
- name: string;
338
- baseline?: BenchmarkData;
339
- benchmarks: BenchmarkData[];
340
- }
341
- interface BenchmarkData {
342
- name: string;
343
- samples: number[];
344
- warmupSamples?: number[];
345
- allocationSamples?: number[];
346
- heapSamples?: number[];
347
- gcEvents?: GcEvent[];
348
- optSamples?: number[];
349
- pausePoints?: PausePoint[];
350
- stats: {
351
- min: number;
352
- max: number;
353
- avg: number;
354
- p50: number;
355
- p75: number;
356
- p99: number;
357
- p999: number;
358
- };
359
- heapSize?: {
360
- min: number;
361
- max: number;
362
- avg: number;
363
- };
364
- sectionStats?: FormattedStat[];
365
- comparisonCI?: DifferenceCI;
366
- }
367
- interface FormattedStat {
368
- label: string;
369
- value: string;
370
- groupTitle?: string;
371
- }
372
- interface GcEvent {
373
- offset: number;
374
- duration: number;
375
- }
376
- interface PausePoint {
377
- sampleIndex: number;
378
- durationMs: number;
379
- }
380
- interface GitVersion {
381
- hash: string;
382
- date: string;
383
- dirty?: boolean;
384
- }
385
- 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 */
386
278
  interface HistogramBin {
279
+ /** Bin center value */
387
280
  x: number;
388
281
  count: number;
389
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
+ */
390
287
  interface DifferenceCI {
288
+ /** Observed percentage difference (current - baseline) / baseline */
391
289
  percent: number;
290
+ /** Confidence interval [lower, upper] in percent */
392
291
  ci: [number, number];
292
+ /** Whether the CI excludes zero: "faster", "slower", or "uncertain" */
393
293
  direction: CIDirection;
294
+ /** Bootstrap distribution histogram for visualization */
394
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;
395
325
  }
396
- interface HtmlReportOptions {
397
- openBrowser: boolean;
398
- outputPath?: string;
326
+ interface DiffColumn<T> extends ColumnFormat<T> {
327
+ diffFormatter?: (value: unknown, baseline: unknown) => string | null;
328
+ formatter?: undefined;
329
+ diffKey: keyof T;
399
330
  }
400
- interface HtmlReportResult {
401
- reportDir: string;
402
- server?: node_http0.Server;
403
- closeServer?: () => void;
331
+ interface ColumnFormat<T> {
332
+ key: keyof T;
333
+ title: string;
334
+ alignment?: Alignment;
335
+ width?: number;
404
336
  }
337
+ /** Build formatted table with column groups and baseline diffs. */
405
338
  //#endregion
406
- //#region src/html/HtmlReport.d.ts
407
- /** Generate HTML report from prepared data and optionally open in browser */
408
- declare function generateHtmlReport(data: ReportData, options: HtmlReportOptions): Promise<HtmlReportResult>;
409
- //#endregion
410
- //#region src/html/HtmlTemplate.d.ts
411
- /** Format ISO date as local time with UTC: "Jan 9, 2026, 3:45 PM (2026-01-09T23:45:00Z)" */
412
- 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;
413
379
  //#endregion
414
- //#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
+ }
415
387
  /** Get current git version info. For dirty repos, uses most recent modified file date. */
416
388
  declare function getCurrentGitVersion(): GitVersion | undefined;
417
389
  /** Read baseline version from .baseline-version file */
@@ -419,204 +391,451 @@ declare function getBaselineVersion(baselineDir?: string): GitVersion | undefine
419
391
  /** Format git version for display: "abc1234 (Jan 9, 2026, 3:45 PM)" or "abc1234*" if dirty */
420
392
  declare function formatGitVersion(version: GitVersion): string;
421
393
  //#endregion
422
- //#region src/heap-sample/HeapSampleReport.d.ts
423
- interface CallFrame {
424
- 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 */
425
540
  url: string;
541
+ /** 1-indexed line number */
426
542
  line: number;
427
- col: number;
543
+ /** 1-indexed column number (undefined when unknown) */
544
+ col?: number;
428
545
  }
429
- 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} */
430
551
  interface HeapReportOptions {
552
+ /** Max sites to display */
431
553
  topN: number;
554
+ /** Caller stack frames to show per site (default 3) */
432
555
  stackDepth?: number;
556
+ /** Multi-line format with file paths (default false) */
433
557
  verbose?: boolean;
558
+ /** Dump every raw sample */
559
+ raw?: boolean;
560
+ /** Filter to user code only, hiding runtime internals */
434
561
  userOnly?: boolean;
562
+ /** Predicate for user vs internal code (default {@link isNodeUserCode}) */
435
563
  isUserCode?: UserCodeFilter;
564
+ /** Total bytes across all nodes (before filtering) */
436
565
  totalAll?: number;
566
+ /** Total bytes for user code only */
437
567
  totalUserCode?: number;
568
+ /** Number of samples taken */
438
569
  sampleCount?: number;
439
570
  }
440
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
441
576
  //#region src/matrix/MatrixReport.d.ts
442
- /** Custom column definition for extra computed metrics */
443
- interface ExtraColumn {
444
- key: string;
445
- title: string;
446
- groupTitle?: string;
447
- extract: (caseResult: CaseResult) => unknown;
448
- formatter?: (value: unknown) => string;
449
- }
450
- /** Options for matrix report generation */
577
+ /** Options for {@link reportMatrixResults} */
451
578
  interface MatrixReportOptions {
452
- extraColumns?: ExtraColumn[];
453
- sections?: ResultsMapper[];
579
+ /** ReportSection sections (default: [timeSection, runsSection]) */
580
+ sections?: ReportSection[];
581
+ /** Custom title for the variant column (default: "variant") */
454
582
  variantTitle?: string;
583
+ /** Comparison options (equivalence margin, batch trimming) */
584
+ comparison?: ComparisonOptions;
455
585
  }
456
- /** Format matrix results as one table per case */
586
+ /** Format matrix results as text, with one table per case */
457
587
  declare function reportMatrixResults(results: MatrixResults, options?: MatrixReportOptions): string;
458
- /** GC statistics columns - derived from gcStatsSection for consistency */
459
- declare const gcStatsColumns: ExtraColumn[];
460
- /** GC pause time column */
461
- declare const gcPauseColumn: ExtraColumn;
462
- /** Heap sampling total bytes column */
463
- declare const heapTotalColumn: ExtraColumn;
464
588
  //#endregion
465
- //#region src/cli/RunBenchCLI.d.ts
466
- /** Parse CLI with custom configuration */
467
- declare function parseBenchArgs<T = DefaultCliArgs>(configureArgs?: Configure<T>): T & DefaultCliArgs;
468
- /** Run suite with CLI arguments */
469
- declare function runBenchmarks(suite: BenchSuite, args: DefaultCliArgs): Promise<ReportGroup[]>;
470
- /** Generate table with standard sections */
471
- declare function defaultReport(groups: ReportGroup[], args: DefaultCliArgs): string;
472
- /** Run benchmarks, display table, and optionally generate HTML report */
473
- declare function benchExports(suite: BenchSuite, args: DefaultCliArgs): Promise<void>;
474
- /** Print heap allocation reports for benchmarks with heap profiles */
475
- declare function printHeapReports(groups: ReportGroup[], options: HeapReportOptions): void;
476
- /** Run benchmarks and display table. Suite is optional with --url (browser mode). */
477
- declare function runDefaultBench(suite?: BenchSuite, configureArgs?: Configure<any>): Promise<void>;
478
- /** 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. */
479
597
  declare function reportOptStatus(groups: ReportGroup[]): void;
480
- /** @return true if any result has the specified field with a defined value */
481
- declare function hasField(results: ReportGroup[], field: keyof MeasuredResults): boolean;
482
- interface ExportOptions {
483
- results: ReportGroup[];
484
- args: DefaultCliArgs;
485
- sections?: any[];
486
- suiteName?: string;
487
- currentVersion?: GitVersion;
488
- baselineVersion?: GitVersion;
489
- }
490
- /** Export reports (HTML, JSON, Perfetto) based on CLI args */
491
- declare function exportReports(options: ExportOptions): Promise<void>;
492
- /** Run matrix suite with CLI arguments.
493
- * no options ==> defaultCases/defaultVariants, --filter ==> subset of defaults,
494
- * --all --filter ==> subset of all, --all ==> all cases/variants */
495
- declare function runMatrixSuite(suite: MatrixSuite, args: DefaultCliArgs): Promise<MatrixResults[]>;
496
- /** Convert CLI args to matrix run options */
497
- declare function cliToMatrixOptions(args: DefaultCliArgs): RunMatrixOptions;
498
- /** 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. */
499
601
  declare function defaultMatrixReport(results: MatrixResults[], reportOptions?: MatrixReportOptions, args?: DefaultCliArgs): string;
500
- /** Run matrix suite with full CLI handling (parse, run, report, export) */
501
- declare function runDefaultMatrixBench(suite: MatrixSuite, configureArgs?: Configure<any>, reportOptions?: MatrixReportOptions): Promise<void>;
502
- /** Convert MatrixResults to ReportGroup[] for export compatibility */
602
+ /** Convert MatrixResults to ReportGroup[] for the standard export pipeline. */
503
603
  declare function matrixToReportGroups(results: MatrixResults[]): ReportGroup[];
504
- interface MatrixExportOptions {
505
- sections?: any[];
506
- currentVersion?: GitVersion;
507
- baselineVersion?: GitVersion;
508
- }
509
- /** Run matrix benchmarks, display table, and generate exports */
604
+ //#endregion
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. */
510
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[]>;
511
624
  //#endregion
512
- //#region src/export/JsonFormat.d.ts
513
- /** Complete benchmark data structure for JSON export */
514
- interface BenchmarkJsonData {
515
- meta: {
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[]>;
628
+ //#endregion
629
+ //#region src/export/SpeedscopeTypes.d.ts
630
+ /** Shared speedscope file format types and frame interning utilities. */
631
+ /** speedscope file format (https://www.speedscope.app/file-format-schema.json) */
632
+ interface SpeedscopeFile {
633
+ $schema: "https://www.speedscope.app/file-format-schema.json";
634
+ shared: {
635
+ frames: SpeedscopeFrame[];
636
+ };
637
+ profiles: SpeedscopeProfile[];
638
+ name?: string;
639
+ exporter?: string;
640
+ }
641
+ /** A single call frame with optional source location */
642
+ interface SpeedscopeFrame {
643
+ name: string;
644
+ file?: string;
645
+ line?: number;
646
+ col?: number;
647
+ }
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 {
652
+ type: "sampled";
653
+ name: string;
654
+ unit: "bytes";
655
+ startValue: number;
656
+ endValue: number;
657
+ samples: number[][];
658
+ weights: number[];
659
+ }
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. */
673
+ declare function exportSpeedscope(groups: ReportGroup[], outputPath: string): string | undefined;
674
+ /** Convert a single HeapProfile to speedscope format. */
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;
678
+ //#endregion
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: {
516
684
  timestamp: string;
517
- version: string;
518
- args: Record<string, any>;
519
- environment: {
685
+ bencherVersion: string;
686
+ cliArgs?: Record<string, unknown>;
687
+ cliDefaults?: Record<string, unknown>;
688
+ gcTrackingEnabled?: boolean;
689
+ currentVersion?: GitVersion;
690
+ baselineVersion?: GitVersion;
691
+ environment?: {
520
692
  node: string;
521
693
  platform: string;
522
- arch?: string;
694
+ arch: string;
523
695
  };
524
696
  };
525
- suites: BenchmarkSuite[];
526
- }
527
- interface BenchmarkSuite {
528
- name: string;
529
- groups: BenchmarkGroup[];
530
697
  }
698
+ /** A named group of benchmarks, optionally compared against a baseline. */
531
699
  interface BenchmarkGroup {
532
700
  name: string;
533
- baseline?: BenchmarkResult;
534
- benchmarks: BenchmarkResult[];
701
+ baseline?: BenchmarkEntry;
702
+ benchmarks: BenchmarkEntry[];
703
+ warnings?: string[];
535
704
  }
536
- interface BenchmarkResult {
705
+ /** One benchmark's raw data, statistics, and optional comparison results. */
706
+ interface BenchmarkEntry {
537
707
  name: string;
538
- status: "completed" | "running" | "failed";
539
- /** Raw execution time samples in milliseconds */
540
708
  samples: number[];
541
- /** Statistical summaries */
542
- time: {
543
- min: number;
544
- max: number;
545
- mean: number;
546
- p50: number;
547
- p75: number;
548
- p99: number;
549
- p999: number;
550
- };
551
- /** Optional performance metrics */
709
+ warmupSamples?: number[];
710
+ allocationSamples?: number[];
711
+ heapSamples?: number[];
712
+ gcEvents?: GcEvent[];
713
+ optSamples?: number[];
714
+ pausePoints?: PausePoint[];
715
+ batchOffsets?: number[];
716
+ stats: BenchmarkStats;
552
717
  heapSize?: {
553
718
  min: number;
554
719
  max: number;
555
- mean: number;
556
- };
557
- gcTime?: {
558
- min: number;
559
- max: number;
560
- mean: number;
561
- };
562
- cpu?: {
563
- instructions?: number;
564
- cycles?: number;
565
- cacheMisses?: number;
566
- branchMisses?: number;
567
- };
568
- /** Execution metadata */
569
- execution: {
570
- iterations: number;
571
- totalTime: number;
572
- warmupRuns?: number;
573
- };
574
- /** Adaptive mode results */
575
- adaptive?: {
576
- confidenceInterval: {
577
- lower: number;
578
- upper: number;
579
- margin: number;
580
- marginPercent: number;
581
- confidence: number;
582
- };
583
- converged: boolean;
584
- stopReason: "threshold_met" | "max_time" | "max_iterations";
585
- };
586
- /** Error information */
587
- error?: {
588
- message: string;
589
- type: string;
590
- stackTrace?: string;
720
+ avg: number;
591
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;
592
788
  }
593
789
  //#endregion
594
- //#region src/export/PerfettoExport.d.ts
595
- /** Export benchmark results to Perfetto-compatible trace file */
596
- declare function exportPerfettoTrace(groups: ReportGroup[], outputPath: string, args: DefaultCliArgs): void;
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;
799
+ }
597
800
  //#endregion
598
- //#region src/HtmlDataPrep.d.ts
599
- interface PrepareHtmlOptions {
600
- cliArgs?: Record<string, unknown>;
601
- sections?: ResultsMapper[];
602
- currentVersion?: GitVersion;
603
- baselineVersion?: GitVersion;
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;
604
823
  }
605
- /** Prepare ReportData from benchmark results for HTML rendering */
606
- declare function prepareHtmlData(groups: ReportGroup[], options: PrepareHtmlOptions): ReportData;
607
824
  //#endregion
608
- //#region src/matrix/CaseLoader.d.ts
609
- /** Module that exports case definitions */
610
- interface CasesModule<T = unknown> {
611
- cases: string[];
612
- defaultCases?: string[];
613
- defaultVariants?: string[];
614
- loadCase?: (id: string) => LoadedCase<T> | Promise<LoadedCase<T>>;
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;
615
832
  }
616
- /** Load a cases module by URL */
617
- declare function loadCasesModule<T = unknown>(moduleUrl: string): Promise<CasesModule<T>>;
618
- /** Load case data from a CasesModule or pass through the caseId */
619
- declare function loadCaseData<T>(casesModule: CasesModule<T> | undefined, caseId: string): Promise<LoadedCase<T>>;
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;
620
839
  //#endregion
621
840
  //#region src/matrix/MatrixFilter.d.ts
622
841
  /** Filter for matrix case/variant selection */
@@ -624,91 +843,81 @@ interface MatrixFilter {
624
843
  case?: string;
625
844
  variant?: string;
626
845
  }
627
- /** Parse filter string: "case/variant", "case/", "/variant", or "case" */
628
- declare function parseMatrixFilter(filter: string): MatrixFilter;
629
846
  /** Filtered matrix with explicit case and variant lists */
630
847
  interface FilteredMatrix<T = unknown> extends BenchMatrix<T> {
631
848
  filteredCases?: string[];
632
849
  filteredVariants?: string[];
633
850
  }
851
+ /** Parse filter string: "case/variant", "case/", "/variant", or "case" */
852
+ declare function parseMatrixFilter(filter: string): MatrixFilter;
634
853
  /** Apply filter to a matrix, merging with existing filters via intersection */
635
854
  declare function filterMatrix<T>(matrix: FilteredMatrix<T>, filter?: MatrixFilter): Promise<FilteredMatrix<T>>;
636
855
  //#endregion
637
- //#region src/StandardSections.d.ts
638
- interface TimeStats {
639
- mean?: number;
640
- p50?: number;
641
- p99?: number;
642
- }
643
- /** Section: mean, p50, p99 timing */
644
- declare const timeSection: ResultsMapper<TimeStats>;
645
- interface GcSectionStats {
646
- gc?: number;
647
- }
648
- /** Section: GC time as fraction of total benchmark time (Node performance hooks) */
649
- declare const gcSection: ResultsMapper<GcSectionStats>;
650
- interface GcStatsInfo {
651
- allocPerIter?: number;
652
- collected?: number;
653
- scavenges?: number;
654
- fullGCs?: number;
655
- promoPercent?: number;
656
- pausePerIter?: number;
657
- }
658
- /** Section: detailed GC stats from --trace-gc-nvp (allocation, promotion, pauses) */
659
- declare const gcStatsSection: ResultsMapper<GcStatsInfo>;
660
- interface CpuStats {
661
- cpuCacheMiss?: number;
662
- cpuStall?: number;
663
- }
664
- /** Section: CPU L1 cache miss rate and stall rate (requires @mitata/counters) */
665
- declare const cpuSection: ResultsMapper<CpuStats>;
666
- interface RunStats {
667
- runs?: number;
668
- }
669
- /** Section: number of sample iterations */
670
- declare const runsSection: ResultsMapper<RunStats>;
671
- /** Section: total sampling duration in seconds (brackets if >= 30s) */
672
- declare const totalTimeSection: ResultsMapper<{
673
- totalTime?: number;
674
- }>;
675
- interface AdaptiveStats {
676
- median?: number;
677
- mean?: number;
678
- p99?: number;
679
- convergence?: number;
680
- }
681
- /** Section: median, mean, p99, and convergence for adaptive mode */
682
- declare const adaptiveSection: ResultsMapper<AdaptiveStats>;
683
- /** Build generic sections based on CLI flags */
684
- declare function buildGenericSections(args: {
685
- "gc-stats"?: boolean;
686
- "heap-sample"?: boolean;
687
- }): ResultsMapper[];
688
- interface OptStats {
689
- tiers?: string;
690
- deopt?: number;
691
- }
692
- /** Section: V8 optimization tier distribution and deopt count */
693
- declare const optSection: ResultsMapper<OptStats>;
694
- //#endregion
695
- //#region src/StatisticalUtils.d.ts
696
- /** @return mean of values */
697
- declare function average(values: number[]): number;
698
- //#endregion
699
- //#region src/table-util/ConvergenceFormatters.d.ts
700
- /** @return convergence percentage with color for low values */
701
- declare function formatConvergence(v: unknown): string;
702
- //#endregion
703
- //#region src/table-util/Formatters.d.ts
704
- /** 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 */
705
858
  declare function timeMs(ms: unknown): string | null;
706
859
  /** Format integer with thousand separators */
707
860
  declare function integer(x: unknown): string | null;
708
- /** Format bytes with appropriate units (B, KB, MB, GB) */
709
- declare function formatBytes(bytes: unknown): string | null;
861
+ /** Format bytes with appropriate units. Use `space: true` for `1.5 KB` style. */
862
+ declare function formatBytes(bytes: unknown, opts?: {
863
+ space?: boolean;
864
+ }): string | null;
710
865
  /** @return truncated string with ellipsis if over maxLen */
711
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;
712
921
  //#endregion
713
- 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 };
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 };
714
923
  //# sourceMappingURL=index.d.mts.map