ostia 0.2.12 → 0.3.1

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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -358
  3. package/docs/agent-protocol.md +210 -0
  4. package/docs/cli.md +1196 -0
  5. package/docs/config.md +233 -0
  6. package/docs/document-schema.md +224 -0
  7. package/docs/library.md +421 -0
  8. package/docs/preload-recipes.md +169 -0
  9. package/docs/statistics.md +218 -0
  10. package/index.d.ts +923 -679
  11. package/package.json +16 -14
  12. package/src/ab/ab-runner.ts +487 -0
  13. package/src/ab/index.ts +1160 -0
  14. package/src/baseline/index.ts +69 -0
  15. package/src/bench/index.ts +516 -0
  16. package/src/bench/projects.ts +43 -0
  17. package/src/bench/range.ts +27 -0
  18. package/src/bench/registry.ts +426 -0
  19. package/src/bench/run-tasks.ts +179 -0
  20. package/src/bench/run.ts +52 -0
  21. package/src/bench/runner.ts +162 -0
  22. package/src/bench/support.ts +161 -0
  23. package/src/bench/sweep.ts +41 -0
  24. package/src/cache/fingerprint.ts +62 -0
  25. package/src/cache/store.ts +40 -0
  26. package/src/capture/bunflags.ts +92 -0
  27. package/src/capture/cpu-parse.ts +131 -0
  28. package/src/capture/cpu.ts +47 -0
  29. package/src/capture/frames.ts +60 -0
  30. package/src/capture/heap-parse.ts +111 -0
  31. package/src/capture/heap.ts +36 -0
  32. package/src/capture/inspector.ts +47 -0
  33. package/src/capture/jsc-parse.ts +167 -0
  34. package/src/capture/jsc.ts +35 -0
  35. package/src/capture/sampling.ts +5 -0
  36. package/src/ci/index.ts +440 -0
  37. package/src/cli/flags.ts +263 -0
  38. package/{chunk-9sx15b08.js → src/cli/help.ts} +23 -11
  39. package/src/cli/main.ts +18 -0
  40. package/src/cli/output.ts +179 -0
  41. package/src/cli/run.ts +1110 -0
  42. package/src/compare/index.ts +624 -0
  43. package/src/config/env.ts +13 -0
  44. package/src/config/index.ts +283 -0
  45. package/src/config/validate.ts +273 -0
  46. package/src/errors.ts +8 -0
  47. package/src/format.ts +35 -0
  48. package/src/glob.ts +45 -0
  49. package/src/index.ts +60 -0
  50. package/src/ir/cpu.ts +10 -0
  51. package/src/ir/defined.ts +12 -0
  52. package/src/ir/document.ts +491 -0
  53. package/src/ir/fp.ts +28 -0
  54. package/src/ir/git.ts +37 -0
  55. package/src/ir/types.ts +615 -0
  56. package/src/measure/alloc.ts +56 -0
  57. package/src/measure/cpu.ts +91 -0
  58. package/src/measure/environment.ts +38 -0
  59. package/src/measure/inprocess.ts +191 -0
  60. package/src/measure/instructions.ts +139 -0
  61. package/src/measure/loop.ts +64 -0
  62. package/src/measure/noise.ts +55 -0
  63. package/src/measure/paired.ts +304 -0
  64. package/src/measure/peak.ts +201 -0
  65. package/src/measure/timing.ts +263 -0
  66. package/src/profile.ts +110 -0
  67. package/src/renderers/collapsed.ts +42 -0
  68. package/src/renderers/cpu-tree.ts +191 -0
  69. package/src/renderers/cpuprofile.ts +43 -0
  70. package/src/renderers/format.ts +132 -0
  71. package/src/renderers/index.ts +37 -0
  72. package/src/renderers/json.ts +10 -0
  73. package/src/renderers/jsonl.ts +19 -0
  74. package/src/renderers/markdown.ts +543 -0
  75. package/src/renderers/mermaid.ts +90 -0
  76. package/src/renderers/minimal.ts +602 -0
  77. package/src/renderers/paired.ts +223 -0
  78. package/src/renderers/relative.ts +60 -0
  79. package/src/renderers/select.ts +264 -0
  80. package/src/renderers/speedscope.ts +73 -0
  81. package/src/renderers/terminal.ts +470 -0
  82. package/src/renderers/types.ts +27 -0
  83. package/src/spawn/index.ts +387 -0
  84. package/src/stats/bootstrap.ts +151 -0
  85. package/src/stats/index.ts +144 -0
  86. package/src/stats/mannwhitney.ts +82 -0
  87. package/src/time.ts +337 -0
  88. package/src/version.ts +3 -0
  89. package/ab-runner.ts +0 -8
  90. package/chunk-05jfst35.js +0 -28
  91. package/chunk-1g1x9zz2.js +0 -15
  92. package/chunk-23g2rwrn.js +0 -3
  93. package/chunk-468h5412.js +0 -25
  94. package/chunk-4esjfc2m.js +0 -2
  95. package/chunk-ct2xsezd.js +0 -14
  96. package/cli.js +0 -3
  97. package/index.js +0 -2
  98. package/runner.ts +0 -7
package/index.d.ts CHANGED
@@ -1,153 +1,120 @@
1
- export declare function defineConfig(config: OstiaConfigInput): OstiaConfigInput;
2
-
3
- export interface WorkloadConfig {
4
- label?: string;
5
- command?: string[];
6
- suites?: string[];
7
- /** `command` only. Globs of the files the timing depends on: `ostia ci`
8
- * reuses a cached run while their contents are unchanged. Omitted, the
9
- * workload always reruns; `[]` caches until the command or config changes. */
10
- inputs?: string[];
11
- /** `command` only. Runs before every trial (warmup included), unmeasured:
12
- * a command string / argv array, or in `ostia.config.ts` a function. A
13
- * function makes the workload uncacheable for `ostia ci`. */
14
- prepare?: PrepareHook;
15
- /** `command` only. Take timing from a number in the command's own output
16
- * instead of its wall clock; see `TimeSource`. */
17
- timeSource?: TimeSource;
18
- /** `command`: kills a trial (or prepare hook) after this many ms.
19
- * `suites`: kills a suite file's (or isolated task's) process after this
20
- * many ms, overriding `bench.timeoutMs`. Overrides `ostia ci`'s 10-minute
21
- * default. */
1
+ export interface AbOptions {
2
+ suites: string[];
3
+ /** Git ref whose committed tree is the base side (default: `"HEAD"`); the
4
+ * candidate is the working tree, uncommitted changes included. */
5
+ base?: string;
6
+ /** Rounds per workload, each one base batch and one candidate batch of
7
+ * about 10ms (default: 15). */
8
+ rounds?: number;
9
+ /** What to judge each round by: the candidate/base time ratio
10
+ * (`"time"`, the default), or the ratio of instructions each side retired
11
+ * per call (`"instructions"`), which a loaded machine barely moves, so a
12
+ * lower `thresholdPct` holds. Instructions are recorded either way where
13
+ * the machine counts them (see `PairedEvidence.instructions`); asking to
14
+ * judge by them where it can't throws an `OstiaUsageError`. */
15
+ metric?: "time" | "instructions";
16
+ /** Flag a workload whose median candidate/base ratio moves past this many
17
+ * percent (default: 10). */
18
+ thresholdPct?: number;
19
+ /** Fail when the geometric mean of all workloads' ratios is slower than
20
+ * this many percent (default: 1.5): a broad slowdown too small to flag any
21
+ * one workload. */
22
+ geomeanThresholdPct?: number;
23
+ /** Fresh-process repeats of each flagged workload, which only counts when
24
+ * every repeat flags it the same way (default: 2; 0 trusts the first). */
25
+ confirm?: number;
26
+ filter?: string;
27
+ preload?: string[];
28
+ bunFlags?: string[];
29
+ /** Per-suite `preload` / `bunFlags`; see `BenchOptions.projects`. */
30
+ projects?: BenchProject[];
31
+ outDir?: string;
32
+ cwd?: string;
33
+ noiseCheck?: boolean;
34
+ /** Also compare each side's retained heap per call (see
35
+ * `bench({ alloc })`) and how far its first call raises RSS (see
36
+ * `bench({ peakMem })`), each the median of 3 fresh processes per side.
37
+ * Task/group options override these. */
38
+ alloc?: boolean;
39
+ peakMem?: boolean;
40
+ /** Flag a memory reading that moves past this many percent of the base's
41
+ * and past its noise floor (default: 10). A memory regression fails the
42
+ * run. */
43
+ memThresholdPct?: number;
44
+ /** Shell commands run once, in order, in a freshly extracted base tree
45
+ * before it's used: to build what the suites import but git doesn't hold
46
+ * (generated or gitignored files). Each runs with its cwd at the tree's
47
+ * counterpart of `cwd`, the project's `node_modules` linked in, and
48
+ * `OSTIA_AB_SHA` / `OSTIA_AB_CANDIDATE_DIR` (the working tree's `cwd`) in
49
+ * its environment. The tree is cached per commit and command list. */
50
+ baseSetup?: string | string[];
51
+ /** Base trees to keep under `.ostia/ab`, counting this run's: after a
52
+ * run, older ones go, least recently used first, unless one was used in
53
+ * the last hour (another run may still need it). Default: 5. */
54
+ keepTrees?: number;
55
+ /** SIGKILLs a runner process (one suite file or repeat), or a `baseSetup`
56
+ * command, after this many ms. */
22
57
  timeoutMs?: number;
23
- /** `command` only. Exit codes to treat as success; see
24
- * `TimeOptions.ignoreExitCodes`. */
25
- ignoreExitCodes?: number[];
58
+ /** Aborting kills the running process and resolves with the suites that
59
+ * had finished, plus an `aborted` warning; unrun repeats leave their
60
+ * workloads unconfirmed. */
61
+ signal?: AbortSignal;
62
+ /** Called as each setup command, task, confirmation repeat and memory
63
+ * process starts. */
64
+ onProgress?: (progress: AbProgress) => void;
26
65
  }
27
-
66
+ /**
67
+ * Launch settings for the suite files matching `suites`; see
68
+ * `BenchOptions.projects`. */
28
69
  export interface BenchProject {
29
- /** Globs against the current directory. A suite file takes the first
70
+ /**
71
+ * Globs against the current directory. A suite file takes the first
30
72
  * project one of these matches; `ostia bench` with no files also runs
31
73
  * every file they expand to. */
32
74
  suites: string[];
33
- /** Replaces the top-level `preload` for these files; `[]` runs them with
75
+ /**
76
+ * Replaces the top-level `preload` for these files; `[]` runs them with
34
77
  * none. Unset: the top-level list applies. */
35
78
  preload?: string[];
36
79
  /** Replaces the top-level `bunFlags` for these files, as `preload` does. */
37
80
  bunFlags?: string[];
38
81
  }
39
-
40
- interface BenchConfig {
41
- /** Suite file globs, resolved against the config's directory (e.g.
42
- * "bench/**\/*.bench.ts"). Suite files given on the command line replace
43
- * this list. */
44
- suites?: string[];
45
- /** Per-suite `preload`/`bunFlags`, so one tier (e.g. DOM-dependent suites)
46
- * can pay for a setup the others don't need. The first project whose
47
- * `suites` match a file wins; a file no project matches gets the top-level
48
- * `preload`/`bunFlags`. `--preload` / `--bun-flags` replace the matching
49
- * field for every file. */
50
- projects?: BenchProject[];
51
- preload?: string[];
52
- /** Extra flags for the `bun` process that runs each suite file; see
53
- * `BenchOptions.bunFlags`. `--bun-flags` replaces this list. */
54
- bunFlags?: string[];
55
- jobs?: number | "auto";
56
- budgetMs?: number;
57
- samples?: number;
58
- minSamples?: number;
59
- gc?: boolean;
60
- cpu?: boolean;
61
- cpuIntervalUs?: number;
62
- alloc?: boolean;
63
- peakMem?: boolean;
64
- filter?: string;
65
- isolate?: boolean;
66
- outDir?: string;
67
- /** Kills a suite file's (or isolated task's) subprocess after this many
68
- * ms; overrides `ostia ci`'s 10-minute default. */
69
- timeoutMs?: number;
70
- }
71
-
72
- export interface AbConfig {
73
- /** Shell command(s) run once in a freshly extracted base tree, e.g. to
74
- * build gitignored files the suites import; see `AbOptions.baseSetup`.
75
- * `--base-setup` replaces this list. */
76
- setup?: string | string[];
77
- /** Base trees to keep cached; see `AbOptions.keepTrees`. `--keep-trees`
78
- * overrides. Default: 5. */
79
- keepTrees?: number;
80
- /** Judge rounds by `"time"` or `"instructions"`; see `AbOptions.metric`.
81
- * `--metric` overrides. Default: `"time"`. */
82
- metric?: "time" | "instructions";
83
- /** Compare retained heap per call; see `AbOptions.alloc`. `--alloc` /
84
- * `--no-alloc` override. `bench.alloc` doesn't apply to `ab`. */
85
- alloc?: boolean;
86
- /** Compare peak RSS of the first call; see `AbOptions.peakMem`.
87
- * `--peak-mem` / `--no-peak-mem` override. `bench.peakMem` doesn't apply
88
- * to `ab`. */
89
- peakMem?: boolean;
90
- /** Memory verdict threshold, percent; see `AbOptions.memThresholdPct`.
91
- * `--mem-threshold` overrides. Default: 10. */
92
- memThresholdPct?: number;
93
- }
94
-
95
- export interface OstiaConfig {
96
- /** `command` workloads: exact trial count; see `time()`. */
97
- samples?: number;
98
- /** `command` workloads: sampling budget in ms; see `time()`. */
99
- budgetMs?: number;
100
- /** `command` workloads: floor on trials; see `time()`. */
101
- minSamples?: number;
102
- warmup: number;
103
- outDir: string;
104
- baselineDir: string;
105
- baseline: string;
106
- thresholds: Thresholds;
107
- workloads: WorkloadConfig[];
108
- bench?: BenchConfig;
109
- ab?: AbConfig;
110
- /** `ostia ci`'s policy for a workload with no matching baseline row (by
111
- * workload id): `"fail"` exits 2 naming the baseline file, `"warn"` lists
112
- * it in the report. Unset: `"fail"` when every workload is missing (a
113
- * stale or wrong baseline), `"warn"` otherwise. */
114
- onMissingBaseline?: "warn" | "fail";
115
- /** Measure the machine's noise floor once per `ostia ci` run (default
116
- * true) and stamp it on the candidate document, so `compare` widens its
117
- * thresholds accordingly. `--no-noise-check` overrides this per run. */
118
- noiseCheck?: boolean;
119
- }
120
-
121
- export type OstiaConfigInput = Omit<Partial<OstiaConfig>, "thresholds"> & {
122
- thresholds?: Partial<Thresholds>;
82
+ /** What `ab()` is doing, for `onProgress`. Counts start at 1. */
83
+ export type AbProgress = {
84
+ phase: "setup";
85
+ command: string;
86
+ } | {
87
+ phase: "measure";
88
+ suite: number;
89
+ suites: number;
90
+ file: string;
91
+ /** Each suite runs twice, once with each side first. */
92
+ pass: number;
93
+ passes: number;
94
+ task: number;
95
+ tasks: number;
96
+ label: string;
97
+ } | {
98
+ phase: "confirm";
99
+ repeat: number;
100
+ repeats: number;
101
+ label: string;
102
+ } | {
103
+ phase: "memory";
104
+ run: number;
105
+ runs: number;
106
+ side: Side;
107
+ label: string;
123
108
  };
124
-
125
- export interface Thresholds {
126
- timingPct: number;
127
- frameSelfPct: number;
128
- heapTypePct: number;
129
- minFrameSelfUs: number;
130
- /** A `regressed` / `improved` verdict also requires Mann-Whitney `pValue < alpha`. */
131
- alpha: number;
132
- /** Bootstrap resample rounds for the timing CI. */
133
- bootstrapIterations: number;
134
- }
135
-
136
- export declare const DEFAULT_THRESHOLDS: Thresholds;
137
-
138
- export interface CompareResult {
139
- comparisons: Comparison[];
140
- unmatched: {
141
- baseOnly: Workload[];
142
- candOnly: Workload[];
143
- };
144
- /** Every task on either side; see `ProfileDocument.compared`. */
145
- compared: ComparedTask[];
146
- summary: ComparisonSummary;
147
- }
148
-
149
- export declare function compareDocuments(base: ProfileDocument, cand: ProfileDocument, thresholds?: Thresholds): CompareResult;
150
-
109
+ type Side = "base" | "cand";
110
+ /** Paired A/B timing of suite files against a git ref: every task runs on
111
+ * the ref's committed tree (base) and the working tree (candidate) in one
112
+ * process, alternating short batches, and is judged on the per-round time
113
+ * ratio. Drift between two runs minutes apart cancels within a round. What
114
+ * pairing can't cancel is how the JIT compiled each side in that process,
115
+ * so every flagged workload is re-measured in `confirm` fresh processes
116
+ * and only counts when they all agree. */
117
+ export declare function ab(opts: AbOptions): Promise<ProfileDocument>;
151
118
  export interface ProfileDocument {
152
119
  schemaVersion: 2;
153
120
  toolVersion: string;
@@ -163,76 +130,60 @@ export interface ProfileDocument {
163
130
  comparisons?: Comparison[];
164
131
  /** Aggregate across `comparisons`; present wherever `comparisons` is. */
165
132
  comparisonSummary?: ComparisonSummary;
166
- /** Workload ids on only one side of the comparison; present wherever
133
+ /**
134
+ * Workload ids on only one side of the comparison; present wherever
167
135
  * `comparisons` is. */
168
136
  unmatched?: {
169
137
  baseOnly: string[];
170
138
  candOnly: string[];
171
139
  };
172
- /** Every task on either side of the comparison, one entry each: what
140
+ /**
141
+ * Every task on either side of the comparison, one entry each: what
173
142
  * `--format markdown` prints, flat for scripts. Present wherever
174
143
  * `comparisons` is. */
175
144
  compared?: ComparedTask[];
176
- /** Machine conditions at measurement time; absent when the noise check was
145
+ /**
146
+ * Machine conditions at measurement time; absent when the noise check was
177
147
  * skipped. */
178
148
  environment?: Environment;
179
- /** Run-level result of `ostia ab` / `ab()`, whose measurements are
149
+ /**
150
+ * Run-level result of `ostia ab` / `ab()`, whose measurements are
180
151
  * `phase: "paired"`. */
181
152
  ab?: AbSummary;
182
- /** Repo state of the process's cwd; absent outside a git repo. Never part of
183
- * an id or fingerprint, so a commit or dirty tree doesn't orphan a baseline. */
153
+ /**
154
+ * Repo state of the process's cwd; absent outside a git repo. Never part
155
+ * of an id or fingerprint, so a commit or dirty tree doesn't orphan a
156
+ * baseline. */
184
157
  git?: GitMetadata;
185
158
  }
186
-
187
- interface GitMetadata {
188
- sha: string;
189
- branch: string;
190
- dirty: boolean;
191
- }
192
-
193
- interface NoiseFloor {
194
- /** `mad / median` of a reference workload, percent: how noisy the machine is
195
- * right now, independent of what's measured. */
196
- floorPct: number;
197
- referenceMedianNs: number;
198
- samples: number;
199
- /** How much slower (positive) the reference ran at the end of the run than
200
- * at the start, percent: the machine's drift over the run. Absent when the
201
- * run didn't re-measure it (`profile()`, older documents). */
202
- driftPct?: number;
203
- }
204
-
205
- interface Environment {
206
- cpuModel: string;
207
- cores: number;
208
- loadAvg1: number;
209
- loadAvg5: number;
210
- noise: NoiseFloor;
211
- }
212
-
213
159
  export interface Workload {
214
- /** Identifies what is measured, not where or when. Subprocess: a hash of
215
- * argv, `prepare` and `timeSource`, excluding `process.cwd()`. In-process: a
216
- * hash of the function source, or for a registry entry the file, task name
217
- * and `params`. Annotations (`label`, `description`, `baseline`) never
218
- * affect it. */
160
+ /**
161
+ * Identifies what is measured, not where or when. Subprocess: a hash of
162
+ * argv, `prepare` and `timeSource`, excluding `process.cwd()`. In-process:
163
+ * a hash of the function source, or for a registry entry the file, task
164
+ * name and `params`. Annotations (`label`, `description`, `baseline`)
165
+ * never affect it. */
219
166
  id: string;
220
167
  kind: "subprocess" | "inprocess";
221
168
  label?: string;
222
169
  command?: string[];
223
- /** Command-form `prepare` hook run before every trial; part of the id. A
224
- * function-form hook isn't serializable and is omitted (its source is still
225
- * hashed into the id). */
170
+ /**
171
+ * Command-form `prepare` hook run before every trial; part of the id. A
172
+ * function-form hook isn't serializable and is omitted (its source is
173
+ * still hashed into the id). */
226
174
  prepare?: string[];
227
- /** Takes samples from a number in the command's own output instead of the
175
+ /**
176
+ * Takes samples from a number in the command's own output instead of the
228
177
  * wall clock; part of the id. */
229
178
  timeSource?: {
230
179
  pattern: string;
231
180
  group?: number;
232
181
  unit?: "ns" | "us" | "ms" | "s";
233
182
  };
234
- /** `task` is the registry's "group/name" id; `group` is the enclosing
235
- * `group()` name. Renderers prefer `group` over splitting `task` on "/". */
183
+ /**
184
+ * `task` is the registry's "group/name" id; `group` is the enclosing
185
+ * `group()` name. Renderers prefer `group` over splitting `task` on "/".
186
+ * */
236
187
  entry?: {
237
188
  file: string;
238
189
  task: string;
@@ -246,21 +197,21 @@ export interface Workload {
246
197
  groupDescription?: string;
247
198
  /** Ran in a subprocess of its own rather than sharing its suite file's. */
248
199
  isolated?: boolean;
249
- /** From `task(..., { params })` or a `sweep()` point. Part of the id, so
200
+ /**
201
+ * From `task(..., { params })` or a `sweep()` point. Part of the id, so
250
202
  * points sharing a task name don't collide. */
251
203
  params?: Record<string, string | number | boolean>;
252
- /** Ids this task had under its former names (`task(..., { aliases })`), so
204
+ /**
205
+ * Ids this task had under its former names (`task(..., { aliases })`), so
253
206
  * `compare` and `ab` match a base measured before a rename. Never part of
254
207
  * the id. */
255
208
  formerIds?: string[];
256
- /** From `task.skip()` / `group.skip()`: never measured, so no `Measurement`.
257
- * Renderers print a "- skipped" row; `compare` treats it as `unchanged` with
258
- * a `skipped` warning. */
209
+ /**
210
+ * From `task.skip()` / `group.skip()`: never measured, so no
211
+ * `Measurement`. Renderers print a "- skipped" row; `compare` treats it as
212
+ * `unchanged` with a `skipped` warning. */
259
213
  skipped?: boolean;
260
214
  }
261
-
262
- type Phase = "timing" | "cpu" | "heap" | "memstats" | "paired";
263
-
264
215
  interface Measurement {
265
216
  id: string;
266
217
  workloadId: string;
@@ -274,12 +225,14 @@ interface Measurement {
274
225
  heap?: HeapEvidence;
275
226
  memory?: MemoryEvidence;
276
227
  jit?: JitTierBreakdown;
277
- /** In-process timing, where the machine counts them: instructions the
228
+ /**
229
+ * In-process timing, where the machine counts them: instructions the
278
230
  * task retired per call, one sample per trial (see `InstructionStats`). */
279
231
  instructions?: InstructionStats;
280
232
  /** `phase: "paired"` only; `timing` is then the candidate side. */
281
233
  paired?: PairedEvidence;
282
- /** `phase: "paired"` only: the task threw on one side or both
234
+ /**
235
+ * `phase: "paired"` only: the task threw on one side or both
283
236
  * (`"both"`). Usually instead of `timing`/`paired`; when it threw in a
284
237
  * confirmation repeat, `repeat` (from 1) says which, and `timing`/`paired`
285
238
  * stay as the first process measured them. Either way the task isn't in
@@ -291,15 +244,17 @@ interface Measurement {
291
244
  };
292
245
  warnings: Warning[];
293
246
  artifacts: ArtifactRef[];
294
- /** Trials ran round-robin with the other commands of the same `time()` call,
295
- * so drift over the run hits every command equally. */
247
+ /**
248
+ * Trials ran round-robin with the other commands of the same `time()`
249
+ * call, so drift over the run hits every command equally. */
296
250
  interleaved?: boolean;
297
251
  }
298
-
252
+ type Phase = "timing" | "cpu" | "heap" | "memstats" | "paired";
299
253
  interface Trial {
300
254
  i: number;
301
255
  wallNs: number;
302
- /** The command's self-reported time (ns) under a `timeSource`; these, not
256
+ /**
257
+ * The command's self-reported time (ns) under a `timeSource`; these, not
303
258
  * `wallNs`, are then the `timing.samples`. */
304
259
  reportedNs?: number;
305
260
  exitCode?: number;
@@ -308,11 +263,11 @@ interface Trial {
308
263
  maxRssBytes?: number;
309
264
  /** Killed by `timeoutMs`; `exitCode` is absent. Contributes no sample. */
310
265
  timedOut?: true;
311
- /** Output didn't match the `timeSource` pattern; `reportedNs` is absent
266
+ /**
267
+ * Output didn't match the `timeSource` pattern; `reportedNs` is absent
312
268
  * (never a `wallNs` fallback). Contributes no sample. */
313
269
  timeSourceNoMatch?: true;
314
270
  }
315
-
316
271
  interface TimingStats {
317
272
  unit: "ns";
318
273
  samples: number[];
@@ -331,19 +286,26 @@ interface TimingStats {
331
286
  p75: number;
332
287
  /** 99th percentile, ns. */
333
288
  p99: number;
334
- /** Median absolute deviation, ns: a spread measure that, unlike stddev, the
289
+ /**
290
+ * Median absolute deviation, ns: a spread measure that, unlike stddev, the
335
291
  * long right tail of wall-clock timings doesn't skew. */
336
292
  mad: number;
337
- /** Calls batched into one timed block; absent (read as 1) unless batching
293
+ /**
294
+ * Calls batched into one timed block; absent (read as 1) unless batching
338
295
  * occurred, and always absent for subprocess timing. */
339
296
  batch?: number;
340
297
  }
341
-
342
- interface InstructionStats {
343
- samples: number[];
344
- median: number;
298
+ interface CpuEvidence {
299
+ origin: "cpu-prof" | "inspector" | "jsc-profile";
300
+ samplingIntervalUs: number;
301
+ frames: Frame[];
302
+ nodes: CallNode[];
303
+ totals: FrameTotal[];
304
+ samples?: {
305
+ nodeIds: number[];
306
+ timeDeltasUs: number[];
307
+ };
345
308
  }
346
-
347
309
  interface Frame {
348
310
  key: string;
349
311
  name: string;
@@ -351,32 +313,17 @@ interface Frame {
351
313
  line?: number;
352
314
  col?: number;
353
315
  }
354
-
355
316
  interface CallNode {
356
317
  id: number;
357
318
  frameIx: number;
358
319
  children: number[];
359
320
  }
360
-
361
321
  interface FrameTotal {
362
322
  frameIx: number;
363
323
  selfUs: number;
364
324
  totalUs: number;
365
325
  samples: number;
366
326
  }
367
-
368
- interface CpuEvidence {
369
- origin: "cpu-prof" | "inspector" | "jsc-profile";
370
- samplingIntervalUs: number;
371
- frames: Frame[];
372
- nodes: CallNode[];
373
- totals: FrameTotal[];
374
- samples?: {
375
- nodeIds: number[];
376
- timeDeltasUs: number[];
377
- };
378
- }
379
-
380
327
  interface HeapEvidence {
381
328
  origin: "heap-prof";
382
329
  heapSizeBytes?: number;
@@ -387,27 +334,30 @@ interface HeapEvidence {
387
334
  retainedBytes?: number;
388
335
  }[];
389
336
  }
390
-
391
337
  interface MemoryEvidence {
392
338
  origin: "resourceUsage" | "heapStats";
393
- /** `memstats` only: `"retained"` (`--alloc`, `bytesPerOp`) or `"peak"`
394
- * (`--peak-mem`, `peakBytes`). Absent means `"retained"` on older documents. */
339
+ /**
340
+ * `memstats` only: `"retained"` (`--alloc`, `bytesPerOp`) or `"peak"`
341
+ * (`--peak-mem`, `peakBytes`). Absent means `"retained"` on older
342
+ * documents. */
395
343
  kind?: "retained" | "peak";
396
344
  /** Largest `Trial.maxRssBytes` across a timing measurement's trials. */
397
345
  maxRssBytes?: number;
398
- /** `--alloc`: heap growth per call across one batch bracketed by full GCs,
346
+ /**
347
+ * `--alloc`: heap growth per call across one batch bracketed by full GCs,
399
348
  * so what the calls keep alive (a leak check), not what they allocate. */
400
349
  bytesPerOp?: number;
401
- /** `--peak-mem`: how far one call raised RSS, garbage included; median over
350
+ /**
351
+ * `--peak-mem`: how far one call raised RSS, garbage included; median over
402
352
  * 3 fresh processes. A `peak-hidden` warning says when it may read low. */
403
353
  peakBytes?: number;
404
- /** In-process timing: the JS heap's size as of its last collection, just
354
+ /**
355
+ * In-process timing: the JS heap's size as of its last collection, just
405
356
  * before the task's warmup and just after its last trial. Read without
406
357
  * forcing a GC, so it never perturbs the timing. */
407
358
  heapUsedBeforeBytes?: number;
408
359
  heapUsedAfterBytes?: number;
409
360
  }
410
-
411
361
  interface JitTierBreakdown {
412
362
  origin: "jsc-profile";
413
363
  tiers: {
@@ -422,13 +372,26 @@ interface JitTierBreakdown {
422
372
  samples: number;
423
373
  }[];
424
374
  }
425
-
375
+ /**
376
+ * Instructions retired per call on the thread that ran the task, in user
377
+ * mode: a system call's kernel work and other threads' (JIT compiler, GC
378
+ * helpers, I/O pool) don't count. Unlike time, another process taking the
379
+ * CPU doesn't move it. Includes the timing loop's own few hundred
380
+ * instructions per batch. */
381
+ interface InstructionStats {
382
+ samples: number[];
383
+ median: number;
384
+ }
385
+ /**
386
+ * Evidence of a `phase: "paired"` measurement: base and candidate
387
+ * alternate in batches in one process, so drift cancels in the ratio. */
426
388
  interface PairedEvidence {
427
389
  /** One base batch and one candidate batch per round, alternating order. */
428
390
  rounds: number;
429
391
  /** Calls per side per round. */
430
392
  batch: number;
431
- /** Base per-call time for each round, ns; `ratios[i]` pairs with
393
+ /**
394
+ * Base per-call time for each round, ns; `ratios[i]` pairs with
432
395
  * `baseSamples[i]` and the candidate's `timing.samples[i]`. */
433
396
  baseSamples: number[];
434
397
  baseMedianNs: number;
@@ -438,13 +401,16 @@ interface PairedEvidence {
438
401
  /** 25th/75th percentile of `ratios`. */
439
402
  ratioP25: number;
440
403
  ratioP75: number;
441
- /** Instructions retired per call on each side, where the machine counts
404
+ /**
405
+ * Instructions retired per call on each side, where the machine counts
442
406
  * them; what `AbSummary.metric: "instructions"` judges. */
443
407
  instructions?: PairedInstructions;
444
- /** `AbSummary.metric`'s median ratio past `1 ± threshold` and on the same
408
+ /**
409
+ * `AbSummary.metric`'s median ratio past `1 ± threshold` and on the same
445
410
  * side of 1 in at least three quarters of rounds. */
446
411
  flagged?: "regressed" | "improved";
447
- /** Each fresh-process re-measurement of a flagged workload; `flagged` by
412
+ /**
413
+ * Each fresh-process re-measurement of a flagged workload; `flagged` by
448
414
  * `AbSummary.metric`. */
449
415
  repeats?: {
450
416
  medianRatio: number;
@@ -461,22 +427,28 @@ interface PairedEvidence {
461
427
  confirmed?: boolean;
462
428
  /** `flagged` when confirmed, else `"unchanged"`. */
463
429
  verdict: "regressed" | "improved" | "unchanged";
464
- /** First call's return values were deep-equal on both sides; informational,
430
+ /**
431
+ * First call's return values were deep-equal on both sides; informational,
465
432
  * never a failure. */
466
433
  sameOutput: boolean;
467
- /** Set when the suite file's text differs from the base ref's copy, so
434
+ /**
435
+ * Set when the suite file's text differs from the base ref's copy, so
468
436
  * each side may run a different benchmark (a fixed fixture, a changed
469
437
  * input). With `sameOutput: false` too, the task is "not comparable": its
470
438
  * verdict is `"unchanged"` and it's left out of the geomean. */
471
439
  suiteChanged?: true;
472
- /** `--alloc`: heap each call keeps alive after a full GC, per side, after
440
+ /**
441
+ * `--alloc`: heap each call keeps alive after a full GC, per side, after
473
442
  * a warmup batch; each the median of 3 fresh processes. */
474
443
  retained?: MemoryChange;
475
- /** `--peak-mem`: how far the task's first call raises RSS, per side,
444
+ /**
445
+ * `--peak-mem`: how far the task's first call raises RSS, per side,
476
446
  * each the median of 3 fresh processes. */
477
447
  peak?: MemoryChange;
478
448
  }
479
-
449
+ /**
450
+ * Instructions a paired task retired per call (see `InstructionStats`),
451
+ * from the same rounds as `PairedEvidence`'s times. */
480
452
  interface PairedInstructions {
481
453
  /** Per round, index-aligned with `PairedEvidence.baseSamples`. */
482
454
  baseSamples: number[];
@@ -489,78 +461,49 @@ interface PairedInstructions {
489
461
  ratioP25: number;
490
462
  ratioP75: number;
491
463
  }
492
-
464
+ /** One memory reading on both sides of an `ab()` task, bytes. */
493
465
  interface MemoryChange {
494
466
  baseBytes: number;
495
467
  candBytes: number;
496
- /** Past both `AbSummary.memory.thresholdPct` of the base and
468
+ /**
469
+ * Past both `AbSummary.memory.thresholdPct` of the base and
497
470
  * `floorBytes`; always `"unchanged"` on a not-comparable task. */
498
471
  verdict: "regressed" | "improved" | "unchanged";
499
- /** The smallest change that counts, bytes: 16 KiB over the batch's calls
472
+ /**
473
+ * The smallest change that counts, bytes: 16 KiB over the batch's calls
500
474
  * for `retained`; for `peak`, 1 MiB, or the freed memory a `peak-hidden`
501
475
  * warning reports. */
502
476
  floorBytes: number;
503
477
  }
504
-
505
- interface AbSummary {
506
- base: {
507
- ref: string;
508
- sha: string;
509
- };
510
- /** Suite files, as given, that don't exist at the base ref: their tasks
511
- * are all candidate-only. */
512
- newSuites?: string[];
513
- rounds: number;
514
- /** What verdicts, confirmation and `geomeanPct` judge: each round's time
515
- * ratio, or its instruction ratio (`PairedEvidence.instructions`). */
516
- metric: "time" | "instructions";
517
- thresholdPct: number;
518
- geomeanThresholdPct: number;
519
- /** Workloads measured on both sides. */
520
- matched: number;
521
- /** Confirmed verdicts. */
522
- regressed: number;
523
- improved: number;
524
- unchanged: number;
525
- /** Flagged in-process, but a fresh-process repeat disagreed; counted in
526
- * `unchanged`. */
527
- unconfirmed: number;
528
- /** Workloads whose first call returned different values on each side. */
529
- outputDiffers: number;
530
- /** Workloads whose suite file and output both changed (see
531
- * `PairedEvidence.suiteChanged`); counted in `unchanged`, left out of
532
- * `geomeanPct`. */
533
- notComparable: number;
534
- /** Workloads that threw on either side or both, and so weren't timed;
535
- * not counted in `matched`. */
536
- threw: number;
537
- /** Present when any task had a memory reading (`--alloc`, `--peak-mem`):
538
- * how many tasks' memory regressed or improved, on either reading. */
539
- memory?: {
540
- thresholdPct: number;
541
- regressed: number;
542
- improved: number;
543
- };
544
- /** Geometric mean of the workloads' median `metric` ratios, signed
545
- * percent (negative: candidate faster); a flagged workload contributes its
546
- * median over its main run and repeats. `null` when nothing was paired. */
547
- geomeanPct: number | null;
548
- /** `"fail"` when any workload regressed (confirmed), threw on the
549
- * candidate side only, or `geomeanPct` exceeds `geomeanThresholdPct`, or
550
- * any task's memory regressed. */
551
- verdict: "pass" | "fail";
552
- }
553
-
554
- declare const WARNING_CODES: readonly ["slow-first-run", "outliers-detected", "fast-command", "nonzero-exit", "artifact-missing", "empty-profile", "low-sample-count", "thin-comparison", "noisy-machine", "skipped", "jit-cold", "timeout", "aborted", "time-source-no-match", "environment-mismatch", "peak-hidden", "suite-changed"];
555
-
556
- export type WarningCode = (typeof WARNING_CODES)[number];
557
-
558
478
  export interface Warning {
559
479
  code: WarningCode;
560
480
  message: string;
561
481
  data?: Record<string, unknown>;
562
482
  }
563
-
483
+ export type WarningCode = (typeof WARNING_CODES)[number];
484
+ /**
485
+ * Every `Warning.code`. A runtime array so a test can assert each is
486
+ * emitted.
487
+ */
488
+ declare const WARNING_CODES: readonly [
489
+ "slow-first-run",
490
+ "outliers-detected",
491
+ "fast-command",
492
+ "nonzero-exit",
493
+ "artifact-missing",
494
+ "empty-profile",
495
+ "low-sample-count",
496
+ "thin-comparison",
497
+ "noisy-machine",
498
+ "skipped",
499
+ "jit-cold",
500
+ "timeout",
501
+ "aborted",
502
+ "time-source-no-match",
503
+ "environment-mismatch",
504
+ "peak-hidden",
505
+ "suite-changed"
506
+ ];
564
507
  interface ArtifactRef {
565
508
  id: string;
566
509
  kind: "cpuprofile" | "heapsnapshot";
@@ -568,7 +511,6 @@ interface ArtifactRef {
568
511
  sha256: string;
569
512
  bytes: number;
570
513
  }
571
-
572
514
  export interface Comparison {
573
515
  id: string;
574
516
  baselineMeasurementId: string;
@@ -576,7 +518,8 @@ export interface Comparison {
576
518
  timing?: {
577
519
  medianDeltaPct: number;
578
520
  meanDeltaPct: number;
579
- /** 95% bootstrap CI on the difference of medians, percent of the baseline
521
+ /**
522
+ * 95% bootstrap CI on the difference of medians, percent of the baseline
580
523
  * median. Absent below 5 samples a side (`thin-comparison`). */
581
524
  ci95?: [number, number];
582
525
  /** Two-sided Mann-Whitney U p-value; absent whenever `ci95` is. */
@@ -585,7 +528,10 @@ export interface Comparison {
585
528
  seed?: number;
586
529
  verdict: "improved" | "regressed" | "unchanged";
587
530
  };
588
- /** Caveats about this comparison, e.g. a thin-sample point-estimate verdict. */
531
+ /**
532
+ * Caveats about this comparison, e.g. a thin-sample point-estimate
533
+ * verdict.
534
+ */
589
535
  warnings?: Warning[];
590
536
  frames?: {
591
537
  frameKey: string;
@@ -609,25 +555,31 @@ export interface Comparison {
609
555
  minFrameSelfUs: number;
610
556
  alpha: number;
611
557
  bootstrapIterations: number;
612
- /** `max(timingPct, both documents' noise floors)`: what timing was tested against. */
558
+ /**
559
+ * `max(timingPct, both documents' noise floors)`: what timing was tested
560
+ * against.
561
+ */
613
562
  effectiveTimingPct: number;
614
563
  };
615
564
  verdict: "pass" | "fail";
616
565
  }
617
-
566
+ /** Aggregate view over a `compareDocuments` call's `Comparison[]`. */
618
567
  interface ComparisonSummary {
619
568
  /** `comparisons.length`. */
620
569
  matched: number;
621
570
  regressed: number;
622
571
  improved: number;
623
572
  unchanged: number;
624
- /** Geometric mean of `cand/base` median ratios, signed percent (negative:
573
+ /**
574
+ * Geometric mean of `cand/base` median ratios, signed percent (negative:
625
575
  * candidate faster). `null` when no comparison had a finite ratio. */
626
576
  geomeanPct: number | null;
627
- /** `Comparison.thresholds.effectiveTimingPct`, which is the same for the
577
+ /**
578
+ * `Comparison.thresholds.effectiveTimingPct`, which is the same for the
628
579
  * whole document pair. */
629
580
  effectiveTimingPct: number;
630
- /** The machine's drift, percent, added to the timing threshold: the
581
+ /**
582
+ * The machine's drift, percent, added to the timing threshold: the
631
583
  * largest of each run's own drift (`NoiseFloor.driftPct`) and how far the
632
584
  * reference loop's speed moved between the two runs. Absent when either
633
585
  * document lacks a noise check. */
@@ -635,24 +587,30 @@ interface ComparisonSummary {
635
587
  /** `"fail"` when any comparison's verdict is `"fail"`. */
636
588
  verdict: "pass" | "fail";
637
589
  }
638
-
590
+ /**
591
+ * One task of a `compare`/`ci` run: matched on both sides, or present on
592
+ * only one (`missing-base`: new, or renamed without an alias;
593
+ * `missing-cand`: removed, or renamed). Times in ns, memory in bytes. */
639
594
  interface ComparedTask {
640
595
  /** The candidate's workload id; the base's on a `missing-cand` task. */
641
596
  workloadId: string;
642
597
  /** Display name: the label, else the command, else the id. */
643
598
  task: string;
644
599
  group?: string;
645
- /** Set when the base was matched through one of the task's `aliases`: the
600
+ /**
601
+ * Set when the base was matched through one of the task's `aliases`: the
646
602
  * base's workload id and display name. */
647
603
  renamedFrom?: {
648
604
  workloadId: string;
649
605
  task: string;
650
606
  };
651
607
  verdict: "improved" | "unchanged" | "regressed" | "missing-base" | "missing-cand";
652
- /** The `Comparison` holding this task's frame and heap-type deltas and
608
+ /**
609
+ * The `Comparison` holding this task's frame and heap-type deltas and
653
610
  * warnings; absent on a one-sided task. */
654
611
  comparisonId?: string;
655
- /** Whether the comparison passed the gate (timing, frames, heap types);
612
+ /**
613
+ * Whether the comparison passed the gate (timing, frames, heap types);
656
614
  * absent on a one-sided task, which never fails it. */
657
615
  pass?: boolean;
658
616
  /** Absent on a one-sided or skipped task. */
@@ -673,9 +631,10 @@ interface ComparedTask {
673
631
  /** Memory readings present on both sides; informational, never gated. */
674
632
  memory?: MemoryDelta[];
675
633
  }
676
-
634
+ /** One memory reading of a task on both sides of a `compare`/`ci`, bytes. */
677
635
  interface MemoryDelta {
678
- /** `heapUsedBefore`/`heapUsedAfter`: in-process heap around the timing
636
+ /**
637
+ * `heapUsedBefore`/`heapUsedAfter`: in-process heap around the timing
679
638
  * run; `retained`: `--alloc`; `peak`: `--peak-mem`; `maxRss`: subprocess
680
639
  * timing. */
681
640
  reading: "heapUsedBefore" | "heapUsedAfter" | "retained" | "peak" | "maxRss";
@@ -683,135 +642,106 @@ interface MemoryDelta {
683
642
  candBytes: number;
684
643
  deltaPct: number;
685
644
  }
686
-
687
- export interface PrepareRun {
688
- phase: "warmup" | "timing" | "cpu" | "heap";
689
- index: number;
645
+ interface Environment {
646
+ cpuModel: string;
647
+ cores: number;
648
+ loadAvg1: number;
649
+ loadAvg5: number;
650
+ noise: NoiseFloor;
690
651
  }
691
-
692
- export type PrepareFn = (run: PrepareRun) => unknown;
693
-
694
- export type PrepareHook = string | string[] | PrepareFn;
695
-
696
- export type TimeUnit = "ns" | "us" | "ms" | "s";
697
-
698
- export interface TimeSource {
699
- pattern: string | RegExp;
700
- group?: number;
701
- unit?: TimeUnit;
652
+ interface NoiseFloor {
653
+ /**
654
+ * `mad / median` of a reference workload, percent: how noisy the machine
655
+ * is right now, independent of what's measured. */
656
+ floorPct: number;
657
+ referenceMedianNs: number;
658
+ samples: number;
659
+ /**
660
+ * How much slower (positive) the reference ran at the end of the run than
661
+ * at the start, percent: the machine's drift over the run. Absent when the
662
+ * run didn't re-measure it (`profile()`, older documents). */
663
+ driftPct?: number;
702
664
  }
703
-
704
- export type AbProgress = {
705
- phase: "setup";
706
- command: string;
707
- } | {
708
- phase: "measure";
709
- suite: number;
710
- suites: number;
711
- file: string;
712
- /** Each suite runs twice, once with each side first. */
713
- pass: number;
714
- passes: number;
715
- task: number;
716
- tasks: number;
717
- label: string;
718
- } | {
719
- phase: "confirm";
720
- repeat: number;
721
- repeats: number;
722
- label: string;
723
- } | {
724
- phase: "memory";
725
- run: number;
726
- runs: number;
727
- side: Side;
728
- label: string;
729
- };
730
-
731
- export interface AbOptions {
732
- suites: string[];
733
- /** Git ref whose committed tree is the base side (default: `"HEAD"`); the
734
- * candidate is the working tree, uncommitted changes included. */
735
- base?: string;
736
- /** Rounds per workload, each one base batch and one candidate batch of
737
- * about 10ms (default: 15). */
738
- rounds?: number;
739
- /** What to judge each round by: the candidate/base time ratio
740
- * (`"time"`, the default), or the ratio of instructions each side retired
741
- * per call (`"instructions"`), which a loaded machine barely moves, so a
742
- * lower `thresholdPct` holds. Instructions are recorded either way where
743
- * the machine counts them (see `PairedEvidence.instructions`); asking to
744
- * judge by them where it can't throws an `OstiaUsageError`. */
745
- metric?: "time" | "instructions";
746
- /** Flag a workload whose median candidate/base ratio moves past this many
747
- * percent (default: 10). */
748
- thresholdPct?: number;
749
- /** Fail when the geometric mean of all workloads' ratios is slower than
750
- * this many percent (default: 1.5): a broad slowdown too small to flag any
751
- * one workload. */
752
- geomeanThresholdPct?: number;
753
- /** Fresh-process repeats of each flagged workload, which only counts when
754
- * every repeat flags it the same way (default: 2; 0 trusts the first). */
755
- confirm?: number;
756
- filter?: string;
757
- preload?: string[];
758
- bunFlags?: string[];
759
- /** Per-suite `preload` / `bunFlags`; see `BenchOptions.projects`. */
760
- projects?: BenchProject[];
761
- outDir?: string;
762
- cwd?: string;
763
- noiseCheck?: boolean;
764
- /** Also compare each side's retained heap per call (see
765
- * `bench({ alloc })`) and how far its first call raises RSS (see
766
- * `bench({ peakMem })`), each the median of 3 fresh processes per side.
767
- * Task/group options override these. */
768
- alloc?: boolean;
769
- peakMem?: boolean;
770
- /** Flag a memory reading that moves past this many percent of the base's
771
- * and past its noise floor (default: 10). A memory regression fails the
772
- * run. */
773
- memThresholdPct?: number;
774
- /** Shell commands run once, in order, in a freshly extracted base tree
775
- * before it's used: to build what the suites import but git doesn't hold
776
- * (generated or gitignored files). Each runs with its cwd at the tree's
777
- * counterpart of `cwd`, the project's `node_modules` linked in, and
778
- * `OSTIA_AB_SHA` / `OSTIA_AB_CANDIDATE_DIR` (the working tree's `cwd`) in
779
- * its environment. The tree is cached per commit and command list. */
780
- baseSetup?: string | string[];
781
- /** Base trees to keep under `.ostia/ab`, counting this run's: after a
782
- * run, older ones go, least recently used first, unless one was used in
783
- * the last hour (another run may still need it). Default: 5. */
784
- keepTrees?: number;
785
- /** SIGKILLs a runner process (one suite file or repeat), or a `baseSetup`
786
- * command, after this many ms. */
787
- timeoutMs?: number;
788
- /** Aborting kills the running process and resolves with the suites that
789
- * had finished, plus an `aborted` warning; unrun repeats leave their
790
- * workloads unconfirmed. */
791
- signal?: AbortSignal;
792
- /** Called as each setup command, task, confirmation repeat and memory
793
- * process starts. */
794
- onProgress?: (progress: AbProgress) => void;
665
+ /** Run-level result of `ab()`, stamped on the document as `ab`. */
666
+ interface AbSummary {
667
+ base: {
668
+ ref: string;
669
+ sha: string;
670
+ };
671
+ /**
672
+ * Suite files, as given, that don't exist at the base ref: their tasks
673
+ * are all candidate-only. */
674
+ newSuites?: string[];
675
+ rounds: number;
676
+ /**
677
+ * What verdicts, confirmation and `geomeanPct` judge: each round's time
678
+ * ratio, or its instruction ratio (`PairedEvidence.instructions`). */
679
+ metric: "time" | "instructions";
680
+ thresholdPct: number;
681
+ geomeanThresholdPct: number;
682
+ /** Workloads measured on both sides. */
683
+ matched: number;
684
+ /** Confirmed verdicts. */
685
+ regressed: number;
686
+ improved: number;
687
+ unchanged: number;
688
+ /**
689
+ * Flagged in-process, but a fresh-process repeat disagreed; counted in
690
+ * `unchanged`. */
691
+ unconfirmed: number;
692
+ /** Workloads whose first call returned different values on each side. */
693
+ outputDiffers: number;
694
+ /**
695
+ * Workloads whose suite file and output both changed (see
696
+ * `PairedEvidence.suiteChanged`); counted in `unchanged`, left out of
697
+ * `geomeanPct`. */
698
+ notComparable: number;
699
+ /**
700
+ * Workloads that threw on either side or both, and so weren't timed;
701
+ * not counted in `matched`. */
702
+ threw: number;
703
+ /**
704
+ * Present when any task had a memory reading (`--alloc`, `--peak-mem`):
705
+ * how many tasks' memory regressed or improved, on either reading. */
706
+ memory?: {
707
+ thresholdPct: number;
708
+ regressed: number;
709
+ improved: number;
710
+ };
711
+ /**
712
+ * Geometric mean of the workloads' median `metric` ratios, signed
713
+ * percent (negative: candidate faster); a flagged workload contributes its
714
+ * median over its main run and repeats. `null` when nothing was paired. */
715
+ geomeanPct: number | null;
716
+ /**
717
+ * `"fail"` when any workload regressed (confirmed), threw on the
718
+ * candidate side only, or `geomeanPct` exceeds `geomeanThresholdPct`, or
719
+ * any task's memory regressed. */
720
+ verdict: "pass" | "fail";
795
721
  }
796
-
722
+ interface GitMetadata {
723
+ sha: string;
724
+ branch: string;
725
+ dirty: boolean;
726
+ }
727
+ /** `ab()` can't run: not in a git repository, or `base` isn't a commit. */
797
728
  export declare class AbBaseError extends OstiaUsageError {
798
729
  }
799
-
800
- export declare class AbSuiteError extends Error {
801
- readonly side: Side;
802
- constructor(message: string, side: Side);
730
+ /** The caller's input can't be run as given (missing suite, bad ref, absent
731
+ * baseline): the CLI reports it as a usage error (exit 2) rather than an
732
+ * internal failure. */
733
+ declare class OstiaUsageError extends Error {
803
734
  }
804
-
735
+ /** A `baseSetup` command exited non-zero or timed out. The message names
736
+ * the command and ends with the tail of its output. */
805
737
  export declare class AbSetupError extends Error {
806
738
  }
807
-
808
- export declare function ab(opts: AbOptions): Promise<ProfileDocument>;
809
-
810
- declare class OstiaUsageError extends Error {
739
+ /** One side's suite failed outside any task: on import, with no tasks, or
740
+ * while a task's memory was measured. */
741
+ export declare class AbSuiteError extends Error {
742
+ readonly side: Side;
743
+ constructor(message: string, side: Side);
811
744
  }
812
-
813
- type Side = "base" | "cand";
814
-
815
745
  export interface BenchOptions {
816
746
  suites: string[];
817
747
  /** Wall-clock sampling budget per task, ms (default 500). */
@@ -820,184 +750,228 @@ export interface BenchOptions {
820
750
  samples?: number;
821
751
  minSamples?: number;
822
752
  gc?: boolean;
823
- /** Capture one extra `phase: "cpu"` measurement per task (the task looped
753
+ /**
754
+ * Capture one extra `phase: "cpu"` measurement per task (the task looped
824
755
  * under the JSC sampling profiler for ~2,000 samples, JIT tiers included),
825
756
  * never mixed into the timing numbers. Task/group `cpu` overrides this. */
826
757
  cpu?: boolean;
827
- /** `cpu`'s sampling interval, µs (default: 100). A coarser interval
758
+ /**
759
+ * `cpu`'s sampling interval, µs (default: 100). A coarser interval
828
760
  * lengthens the capture to keep the sample count, up to 10s per task. */
829
761
  cpuIntervalUs?: number;
830
- /** Capture one extra `phase: "memstats"` measurement per task: retained
762
+ /**
763
+ * Capture one extra `phase: "memstats"` measurement per task: retained
831
764
  * heap growth per call, from a batch with `Bun.gc(true)` on both sides.
832
765
  * What the calls keep alive, not what they allocate. Task/group `alloc`
833
766
  * overrides this. */
834
767
  alloc?: boolean;
835
- /** Capture one extra `phase: "memstats"` measurement per task: how far the
768
+ /**
769
+ * Capture one extra `phase: "memstats"` measurement per task: how far the
836
770
  * task's first call raises RSS, garbage included. Median of 3 fresh
837
771
  * processes, each run with `OSTIA_PEAK_MEM=1` in its environment (see
838
772
  * `measurePeakMem`). Task/group `peakMem` overrides this. */
839
773
  peakMem?: boolean;
840
774
  filter?: string;
841
- /** Suite files (or isolated tasks) to run at once, each in its own child
775
+ /**
776
+ * Suite files (or isolated tasks) to run at once, each in its own child
842
777
  * process (default: 1). Concurrent CPU-bound processes contend for cores,
843
778
  * caches and turbo headroom, so timings under `jobs > 1` are noisier and
844
779
  * not like-for-like with a baseline measured at 1. */
845
780
  jobs?: number;
846
781
  outDir?: string;
847
782
  cwd?: string;
848
- /** Give every task its own subprocess instead of sharing its suite file's,
783
+ /**
784
+ * Give every task its own subprocess instead of sharing its suite file's,
849
785
  * isolating JIT tier state, inline caches and heap shape between tasks.
850
786
  * Task/group `isolate` overrides this. Multiplies spawn overhead by task
851
787
  * count instead of file count. */
852
788
  isolate?: boolean;
853
- /** Scripts run, in order, before each suite file loads, in the same
789
+ /**
790
+ * Scripts run, in order, before each suite file loads, in the same
854
791
  * subprocess: install globals (jsdom) or a `Bun.plugin()` loader ahead of
855
792
  * the suite's top-level code. */
856
793
  preload?: string[];
857
- /** Extra flags for the `bun` invocation that runs each suite file (e.g.
794
+ /**
795
+ * Extra flags for the `bun` invocation that runs each suite file (e.g.
858
796
  * `["--conditions", "browser"]`), placed before the runner script path. */
859
797
  bunFlags?: string[];
860
- /** Per-suite `preload` / `bunFlags`: the first project whose `suites` globs
798
+ /**
799
+ * Per-suite `preload` / `bunFlags`: the first project whose `suites` globs
861
800
  * match a suite file (by its path relative to `cwd`) replaces those two
862
801
  * fields for that file, so suites that need no setup don't pay for the
863
802
  * others'. A field a project leaves unset keeps the top-level value above;
864
803
  * `[]` clears it. */
865
804
  projects?: BenchProject[];
866
- /** Measure this machine's noise floor once, before any suite runs
805
+ /**
806
+ * Measure this machine's noise floor once, before any suite runs
867
807
  * (default: true), and stamp it on the document as `environment`. */
868
808
  noiseCheck?: boolean;
869
- /** SIGKILLs a suite file's subprocess (or, under `isolate`, one task's) that
870
- * hasn't finished after this many ms. No default. */
809
+ /**
810
+ * SIGKILLs a suite file's subprocess (or, under `isolate`, one task's)
811
+ * that hasn't finished after this many ms. No default. */
871
812
  timeoutMs?: number;
872
- /** Aborting kills in-flight subprocesses, starts no new ones, and resolves
813
+ /**
814
+ * Aborting kills in-flight subprocesses, starts no new ones, and resolves
873
815
  * (never rejects) with whatever suites/tasks had finished, plus an
874
816
  * `aborted` warning on the last measurement. A suite killed mid-run is
875
817
  * dropped entirely: it only writes its result once, at the end. */
876
818
  signal?: AbortSignal;
877
819
  }
878
-
820
+ /** Measures the tasks each of `suites` registers, one subprocess per file. */
879
821
  export declare function bench(opts: BenchOptions): Promise<ProfileDocument>;
880
-
822
+ /**
823
+ * Geometric sweep points from `start` to `end`, growing by `multiplier`
824
+ * each step and always ending on `end` even if the last step overshot it.
825
+ * Mirrors mitata's `.range(name, start, end, multiplier)` point generation
826
+ * exactly, minus the name templating - build the task name yourself in the
827
+ * loop:
828
+ *
829
+ * for (const size of range(100, 10_000)) {
830
+ * const input = buildInput(size)
831
+ * task(`${size} items`, () => parse(input))
832
+ * }
833
+ *
834
+ * range(100, 10_000) -> [100, 800, 6400, 10000]
835
+ * range(100, 100_000) -> [100, 800, 6400, 51200, 100000]
836
+ */
881
837
  export declare function range(start: number, end: number, multiplier?: number): number[];
882
-
883
- type Hook = () => unknown | Promise<unknown>;
884
-
838
+ export interface GroupOptions {
839
+ /**
840
+ * What this group measures and why. Flows into `Workload.groupDescription`
841
+ * on every task in the group. */
842
+ description?: string;
843
+ /**
844
+ * Default `isolate` for every task in this group, unless a task overrides
845
+ * it with its own `TaskOptions.isolate`. */
846
+ isolate?: boolean;
847
+ /**
848
+ * Default `gc` for every task in this group, unless a task overrides it
849
+ * with its own `TaskOptions.gc`. */
850
+ gc?: boolean;
851
+ /**
852
+ * Default `cpu` for every task in this group, unless a task overrides it
853
+ * with its own `TaskOptions.cpu`. */
854
+ cpu?: boolean;
855
+ /**
856
+ * Default `alloc` for every task in this group, unless a task overrides
857
+ * it with its own `TaskOptions.alloc`. */
858
+ alloc?: boolean;
859
+ /**
860
+ * Default `peakMem` for every task in this group, unless a task
861
+ * overrides it with its own `TaskOptions.peakMem`. */
862
+ peakMem?: boolean;
863
+ /**
864
+ * Runs once, unmeasured, before the group's first task's warmup (not
865
+ * before every task) - in whichever process runs that task, so it works
866
+ * with `isolate`. */
867
+ before?: Hook;
868
+ /** Runs once, unmeasured, after the group's last task's last trial. */
869
+ after?: Hook;
870
+ }
871
+ /** A task body or hook; it may return a promise, which the runner awaits. */
872
+ type Hook = () => unknown;
885
873
  export interface TaskOptions {
886
- /** Marks this task as the Relative reference for its group in the table
874
+ /**
875
+ * Marks this task as the Relative reference for its group in the table
887
876
  * renderer, mirroring mitata's `baseline()`. At most one per group. */
888
877
  baseline?: boolean;
889
878
  /** Per-task time budget; overrides the suite-wide `--budget` / `budgetMs`. */
890
879
  budgetMs?: number;
891
- /** Per-task exact trial count; overrides the suite-wide `--samples` /
880
+ /**
881
+ * Per-task exact trial count; overrides the suite-wide `--samples` /
892
882
  * `samples`. When set, the budget is ignored for this task. */
893
883
  samples?: number;
894
- /** Per-task hard floor on trials; overrides the suite-wide `--min-samples` /
895
- * `minSamples`. */
884
+ /**
885
+ * Per-task hard floor on trials; overrides the suite-wide `--min-samples`
886
+ * / `minSamples`. */
896
887
  minSamples?: number;
897
- /** Former names of this task in the same group, so `compare` and `ab`
888
+ /**
889
+ * Former names of this task in the same group, so `compare` and `ab`
898
890
  * match a base measured before a rename instead of reporting the old name
899
891
  * as removed and the new one as new. */
900
892
  aliases?: string[];
901
- /** What this task measures and why. Flows into `Workload.description` so the
902
- * intent travels with the numbers instead of living only in a source comment. */
893
+ /**
894
+ * What this task measures and why. Flows into `Workload.description` so
895
+ * the intent travels with the numbers instead of living only in a source
896
+ * comment. */
903
897
  description?: string;
904
- /** Give this task its own subprocess instead of sharing its suite file's,
898
+ /**
899
+ * Give this task its own subprocess instead of sharing its suite file's,
905
900
  * isolating its JIT tier state and heap shape from every other task in the
906
901
  * run. Overrides the group's and the suite-wide `bench({ isolate })` /
907
902
  * `--isolate` default for this task only. */
908
903
  isolate?: boolean;
909
- /** Overrides the suite-wide `bench({ gc })` / `--gc` (and any
904
+ /**
905
+ * Overrides the suite-wide `bench({ gc })` / `--gc` (and any
910
906
  * `GroupOptions.gc`) for this task only. */
911
907
  gc?: boolean;
912
- /** Overrides the suite-wide `bench({ cpu })` / `--cpu` (and any
908
+ /**
909
+ * Overrides the suite-wide `bench({ cpu })` / `--cpu` (and any
913
910
  * `GroupOptions.cpu`) for this task only: after the timing measurement,
914
911
  * capture one extra `phase: "cpu"` measurement (JIT tiers included) on
915
912
  * the same workload, never mixed into the timing numbers. */
916
913
  cpu?: boolean;
917
- /** Overrides the suite-wide `bench({ alloc })` / `--alloc` (and any
914
+ /**
915
+ * Overrides the suite-wide `bench({ alloc })` / `--alloc` (and any
918
916
  * `GroupOptions.alloc`) for this task only: after the timing measurement,
919
917
  * capture one extra `phase: "memstats"` measurement of the heap each call
920
918
  * retains (what survives a full GC, not what it allocates). */
921
919
  alloc?: boolean;
922
- /** Overrides the suite-wide `bench({ peakMem })` / `--peak-mem` (and any
920
+ /**
921
+ * Overrides the suite-wide `bench({ peakMem })` / `--peak-mem` (and any
923
922
  * `GroupOptions.peakMem`) for this task only: capture one extra
924
923
  * `phase: "memstats"` measurement of how far one call raises the
925
924
  * process's peak RSS, in fresh processes. */
926
925
  peakMem?: boolean;
927
- /** Structured parameters this task represents (e.g. `{ size: 800, impl:
926
+ /**
927
+ * Structured parameters this task represents (e.g. `{ size: 800, impl:
928
928
  * "fast" }`), written to `Workload.params` and folded into the workload id
929
929
  * so points with the same task name don't collide. Inside `sweep()`, the
930
930
  * current point is inherited automatically; an explicit `params` here
931
931
  * merges over it (explicit keys win). */
932
932
  params?: Record<string, string | number | boolean>;
933
- /** Runs once, unmeasured, immediately before this task's warmup - in the
933
+ /**
934
+ * Runs once, unmeasured, immediately before this task's warmup - in the
934
935
  * task's own process, so it works with `isolate`. No per-trial hook: that
935
936
  * would defeat batching. Use `gc` (Bun.gc between trials) or `isolate`
936
937
  * (a fresh process per task) for per-trial concerns instead. */
937
938
  before?: Hook;
938
- /** Runs once, unmeasured, immediately after this task's last trial. Same
939
+ /**
940
+ * Runs once, unmeasured, immediately after this task's last trial. Same
939
941
  * process/no-per-trial caveats as `before`. */
940
942
  after?: Hook;
941
943
  }
942
-
943
- export interface GroupOptions {
944
- /** What this group measures and why. Flows into `Workload.groupDescription`
945
- * on every task in the group. */
946
- description?: string;
947
- /** Default `isolate` for every task in this group, unless a task overrides
948
- * it with its own `TaskOptions.isolate`. */
949
- isolate?: boolean;
950
- /** Default `gc` for every task in this group, unless a task overrides it
951
- * with its own `TaskOptions.gc`. */
952
- gc?: boolean;
953
- /** Default `cpu` for every task in this group, unless a task overrides it
954
- * with its own `TaskOptions.cpu`. */
955
- cpu?: boolean;
956
- /** Default `alloc` for every task in this group, unless a task overrides
957
- * it with its own `TaskOptions.alloc`. */
958
- alloc?: boolean;
959
- /** Default `peakMem` for every task in this group, unless a task
960
- * overrides it with its own `TaskOptions.peakMem`. */
961
- peakMem?: boolean;
962
- /** Runs once, unmeasured, before the group's first task's warmup (not
963
- * before every task) - in whichever process runs that task, so it works
964
- * with `isolate`. */
965
- before?: Hook;
966
- /** Runs once, unmeasured, after the group's last task's last trial. */
967
- after?: Hook;
968
- }
969
-
970
- type GroupRegistrar = (name: string, fn: () => void, opts?: GroupOptions) => void;
971
-
944
+ /** Registers the tasks `fn` declares under the group `name`. */
945
+ export declare const group: GroupFn;
972
946
  interface GroupFn extends GroupRegistrar {
973
- /** Registers every task inside as skipped: the runner never measures
947
+ /**
948
+ * Registers every task inside as skipped: the runner never measures
974
949
  * them, but the document still carries their workloads (marked
975
950
  * `Workload.skipped`). */
976
951
  skip: GroupRegistrar;
977
- /** When any task or group in the suite uses `.only`, the runner restricts
952
+ /**
953
+ * When any task or group in the suite uses `.only`, the runner restricts
978
954
  * the whole suite file to only those tasks (before `--filter` narrows
979
955
  * further) and prints a one-line notice to stderr. */
980
956
  only: GroupRegistrar;
981
957
  }
982
-
983
- export declare const group: GroupFn;
984
-
985
- type TaskRegistrar = (name: string, fn: () => unknown | Promise<unknown>, opts?: TaskOptions) => void;
986
-
958
+ type GroupRegistrar = (name: string, fn: () => void, opts?: GroupOptions) => void;
959
+ /** Registers `fn` as a benchmark task named `name` in the current group. */
960
+ export declare const task: TaskFn;
987
961
  interface TaskFn extends TaskRegistrar {
988
- /** Registers the task as skipped: the runner never measures it, but the
962
+ /**
963
+ * Registers the task as skipped: the runner never measures it, but the
989
964
  * document still carries its workload (marked `Workload.skipped`) so a
990
965
  * renderer or `compare` can say so explicitly instead of the task simply
991
966
  * being absent. */
992
967
  skip: TaskRegistrar;
993
- /** When any task or group in the suite uses `.only`, the runner restricts
968
+ /**
969
+ * When any task or group in the suite uses `.only`, the runner restricts
994
970
  * the whole suite file to only those tasks (before `--filter` narrows
995
971
  * further) and prints a one-line notice to stderr. */
996
972
  only: TaskRegistrar;
997
973
  }
998
-
999
- export declare const task: TaskFn;
1000
-
974
+ type TaskRegistrar = (name: string, fn: Hook, opts?: TaskOptions) => void;
1001
975
  export interface RunOptions extends MeasureTasksOpts {
1002
976
  /** Regex matched against "group/name" task ids, as in `bench({ filter })`. */
1003
977
  filter?: string;
@@ -1006,45 +980,24 @@ export interface RunOptions extends MeasureTasksOpts {
1006
980
  /** Renderer used for the printed report (default: `"table"`). */
1007
981
  format?: FormatName;
1008
982
  }
1009
-
1010
- export declare function run(opts?: RunOptions): Promise<ProfileDocument>;
1011
-
1012
- type FormatName = "table" | "json" | "markdown" | "jsonl" | "minimal" | "collapsed" | "mermaid" | "speedscope" | "cpuprofile";
1013
-
1014
- export interface VizOptions {
1015
- /** Render this measurement only, instead of every CPU measurement. */
1016
- measurementId?: string;
1017
- }
1018
-
1019
- interface RenderResult {
1020
- text?: string;
1021
- files?: {
1022
- path?: string;
1023
- content: string;
1024
- }[];
1025
- }
1026
-
1027
- interface Renderer<O = unknown> {
1028
- name: FormatName;
1029
- render(doc: ProfileDocument, options: O): Promise<RenderResult>;
1030
- }
1031
-
1032
983
  interface MeasureTasksOpts extends InprocessTimingOptions {
1033
- /** Suite-wide default for capturing an extra `phase: "cpu"` measurement per
984
+ /**
985
+ * Suite-wide default for capturing an extra `phase: "cpu"` measurement per
1034
986
  * task (task/group `cpu` still wins). */
1035
987
  cpu?: boolean;
1036
988
  /** `cpu`'s sampling interval, µs (default: 100). */
1037
989
  cpuIntervalUs?: number;
1038
- /** Suite-wide default for capturing an extra `phase: "memstats"`
990
+ /**
991
+ * Suite-wide default for capturing an extra `phase: "memstats"`
1039
992
  * measurement per task (task/group `alloc` still wins). */
1040
993
  alloc?: boolean;
1041
994
  /** Stamped onto every workload: it ran in a subprocess dedicated to it. */
1042
995
  markIsolated?: boolean;
1043
- /** Measure this machine's noise floor before the first task (default:
996
+ /**
997
+ * Measure this machine's noise floor before the first task (default:
1044
998
  * true) and stamp it on the document as `environment`. */
1045
999
  noiseCheck?: boolean;
1046
1000
  }
1047
-
1048
1001
  interface InprocessTimingOptions {
1049
1002
  /** Wall-clock budget for the sampling loop, per task (default: 500). */
1050
1003
  budgetMs?: number;
@@ -1054,23 +1007,243 @@ interface InprocessTimingOptions {
1054
1007
  * the floor is cost-aware (see `defaultSampleFloor`). */
1055
1008
  minSamples?: number;
1056
1009
  /** Warmup budget as a fraction of `budgetMs` (default: 0.1); unlike
1057
- * `time()`'s `warmup`, which is a trial count. Always runs at least one call. */
1010
+ * `time()`'s `warmup`, which is a trial count. Always runs at least one
1011
+ * call. */
1058
1012
  warmup?: number;
1059
1013
  gc?: boolean;
1060
1014
  }
1061
-
1062
- export declare function keep(value: unknown): void;
1063
-
1015
+ type FormatName = "table" | "json" | "markdown" | "jsonl" | "minimal" | "collapsed" | "mermaid" | "speedscope" | "cpuprofile";
1016
+ /** In-file entrypoint: call at the bottom of a suite file run directly with
1017
+ * `bun suite.ts` to measure every registered `group()`/`task()`, print a
1018
+ * report, and return the document.
1019
+ *
1020
+ * Everything runs in the current process, so `TaskOptions.isolate` is
1021
+ * ignored. Prefer `ostia bench`/`bench()` for numbers you'll
1022
+ * `compare`/`ci` against. */
1023
+ export declare function run(opts?: RunOptions): Promise<ProfileDocument>;
1024
+ /** Cartesian product over `dims`, calling `fn` once per point. Inside `fn`,
1025
+ * `task()` calls automatically inherit the point as their params (an
1026
+ * explicit `TaskOptions.params` merges over it, explicit keys win):
1027
+ *
1028
+ * group("parse", () => {
1029
+ * sweep({ size: range(100, 10_000), impl: ["current", "fast"] }, ({ size, impl }) => {
1030
+ * const input = build(size)
1031
+ * task(`${impl}`, () => impls[impl](input))
1032
+ * })
1033
+ * })
1034
+ */
1035
+ export declare function sweep<T extends Record<string, readonly unknown[]>>(dims: T, fn: (point: SweepPoint<T>) => void): void;
1064
1036
  type SweepPoint<T extends Record<string, readonly unknown[]>> = {
1065
1037
  [K in keyof T]: T[K][number];
1066
1038
  };
1067
-
1068
- export declare function sweep<T extends Record<string, readonly unknown[]>>(dims: T, fn: (point: SweepPoint<T>) => void): void;
1069
-
1039
+ export interface CompareResult {
1040
+ comparisons: Comparison[];
1041
+ unmatched: {
1042
+ baseOnly: Workload[];
1043
+ candOnly: Workload[];
1044
+ };
1045
+ /** Every task on either side; see `ProfileDocument.compared`. */
1046
+ compared: ComparedTask[];
1047
+ summary: ComparisonSummary;
1048
+ }
1049
+ export interface Thresholds {
1050
+ timingPct: number;
1051
+ frameSelfPct: number;
1052
+ heapTypePct: number;
1053
+ minFrameSelfUs: number;
1054
+ /**
1055
+ * A `regressed` / `improved` verdict also requires Mann-Whitney `pValue <
1056
+ * alpha`.
1057
+ */
1058
+ alpha: number;
1059
+ /** Bootstrap resample rounds for the timing CI. */
1060
+ bootstrapIterations: number;
1061
+ }
1062
+ /**
1063
+ * Compares every `cand.workloads` entry that has a match in `base` (in
1064
+ * candidate order, as `ostia ci` does), and reports what matched only one
1065
+ * side in `unmatched` rather than dropping it. */
1066
+ export declare function compareDocuments(base: ProfileDocument, cand: ProfileDocument, thresholds?: Thresholds): CompareResult;
1067
+ /**
1068
+ * The thresholds `compareDocuments` uses when given none; spread over it
1069
+ * to change one field.
1070
+ */
1071
+ export declare const DEFAULT_THRESHOLDS: Thresholds;
1072
+ /**
1073
+ * Settings for `ostia ab` only; it reads the rest (suites, filter,
1074
+ * preload, ...) from `bench`. */
1075
+ export interface AbConfig {
1076
+ /**
1077
+ * Shell command(s) run once in a freshly extracted base tree, e.g. to
1078
+ * build gitignored files the suites import; see `AbOptions.baseSetup`.
1079
+ * `--base-setup` replaces this list. */
1080
+ setup?: string | string[];
1081
+ /**
1082
+ * Base trees to keep cached; see `AbOptions.keepTrees`. `--keep-trees`
1083
+ * overrides. Default: 5. */
1084
+ keepTrees?: number;
1085
+ /**
1086
+ * Judge rounds by `"time"` or `"instructions"`; see `AbOptions.metric`.
1087
+ * `--metric` overrides. Default: `"time"`. */
1088
+ metric?: "time" | "instructions";
1089
+ /**
1090
+ * Compare retained heap per call; see `AbOptions.alloc`. `--alloc` /
1091
+ * `--no-alloc` override. `bench.alloc` doesn't apply to `ab`. */
1092
+ alloc?: boolean;
1093
+ /**
1094
+ * Compare peak RSS of the first call; see `AbOptions.peakMem`.
1095
+ * `--peak-mem` / `--no-peak-mem` override. `bench.peakMem` doesn't apply
1096
+ * to `ab`. */
1097
+ peakMem?: boolean;
1098
+ /**
1099
+ * Memory verdict threshold, percent; see `AbOptions.memThresholdPct`.
1100
+ * `--mem-threshold` overrides. Default: 10. */
1101
+ memThresholdPct?: number;
1102
+ }
1103
+ export interface OstiaConfig {
1104
+ /** `command` workloads: exact trial count; see `time()`. */
1105
+ samples?: number;
1106
+ /** `command` workloads: sampling budget in ms; see `time()`. */
1107
+ budgetMs?: number;
1108
+ /** `command` workloads: floor on trials; see `time()`. */
1109
+ minSamples?: number;
1110
+ warmup: number;
1111
+ outDir: string;
1112
+ baselineDir: string;
1113
+ baseline: string;
1114
+ thresholds: Thresholds;
1115
+ workloads: WorkloadConfig[];
1116
+ bench?: BenchConfig;
1117
+ ab?: AbConfig;
1118
+ /**
1119
+ * `ostia ci`'s policy for a workload with no matching baseline row (by
1120
+ * workload id): `"fail"` exits 2 naming the baseline file, `"warn"` lists
1121
+ * it in the report. Unset: `"fail"` when every workload is missing (a
1122
+ * stale or wrong baseline), `"warn"` otherwise. */
1123
+ onMissingBaseline?: "warn" | "fail";
1124
+ /**
1125
+ * Measure the machine's noise floor once per `ostia ci` run (default
1126
+ * true) and stamp it on the candidate document, so `compare` widens its
1127
+ * thresholds accordingly. `--no-noise-check` overrides this per run. */
1128
+ noiseCheck?: boolean;
1129
+ }
1130
+ /**
1131
+ * Exactly one of `command` (a subprocess to time) / `suites` (in-process
1132
+ * `group()`/`task()` suite file globs, run via `bench()`, each task gated
1133
+ * individually) must be given. */
1134
+ export interface WorkloadConfig {
1135
+ label?: string;
1136
+ command?: string[];
1137
+ suites?: string[];
1138
+ /**
1139
+ * `command` only. Globs of the files the timing depends on: `ostia ci`
1140
+ * reuses a cached run while their contents are unchanged. Omitted, the
1141
+ * workload always reruns; `[]` caches until the command or config changes.
1142
+ * */
1143
+ inputs?: string[];
1144
+ /**
1145
+ * `command` only. Runs before every trial (warmup included), unmeasured:
1146
+ * a command string / argv array, or in `ostia.config.ts` a function. A
1147
+ * function makes the workload uncacheable for `ostia ci`. */
1148
+ prepare?: PrepareHook;
1149
+ /**
1150
+ * `command` only. Take timing from a number in the command's own output
1151
+ * instead of its wall clock; see `TimeSource`. */
1152
+ timeSource?: TimeSource;
1153
+ /**
1154
+ * `command`: kills a trial (or prepare hook) after this many ms.
1155
+ * `suites`: kills a suite file's (or isolated task's) process after this
1156
+ * many ms, overriding `bench.timeoutMs`. Overrides `ostia ci`'s 10-minute
1157
+ * default. */
1158
+ timeoutMs?: number;
1159
+ /**
1160
+ * `command` only. Exit codes to treat as success; see
1161
+ * `TimeOptions.ignoreExitCodes`. */
1162
+ ignoreExitCodes?: number[];
1163
+ }
1164
+ /**
1165
+ * Runs unmeasured before every trial of a command, in its `cwd`/`env`
1166
+ * (hyperfine's `--prepare`): a shell-less command (string,
1167
+ * whitespace-split, or argv array) that must exit 0 or the run aborts, or
1168
+ * a function. */
1169
+ export type PrepareHook = string | string[] | PrepareFn;
1170
+ /** Return value ignored; a returned promise is awaited. */
1171
+ export type PrepareFn = (run: PrepareRun) => unknown;
1172
+ /**
1173
+ * `index` counts from 0 within each phase, so "first run" logic checks
1174
+ * `phase === "warmup" && index === 0` (or `phase === "timing"` when warmup
1175
+ * is 0). */
1176
+ export interface PrepareRun {
1177
+ phase: "warmup" | "timing" | "cpu" | "heap";
1178
+ index: number;
1179
+ }
1180
+ /**
1181
+ * Take a command's timing from a number in its own stdout/stderr instead
1182
+ * of the wall clock (e.g. a build tool's `built in 342ms` line). `pattern`
1183
+ * is matched against stdout, then stderr; `group` (default 1) holds the
1184
+ * number; `unit` defaults to "ms". A trial that doesn't match contributes
1185
+ * no sample (`time-source-no-match` warning); if every trial misses, the
1186
+ * workload has no timing stats. A `RegExp` pattern must not carry the `g`,
1187
+ * `y`, or `d` flag: it is reused across trials, and `lastIndex` would make
1188
+ * it alternate match/no-match. */
1189
+ export interface TimeSource {
1190
+ pattern: string | RegExp;
1191
+ group?: number;
1192
+ unit?: TimeUnit;
1193
+ }
1194
+ export type TimeUnit = "ns" | "us" | "ms" | "s";
1195
+ interface BenchConfig {
1196
+ /**
1197
+ * Suite file globs, resolved against the config's directory (e.g.
1198
+ * "bench/**\/*.bench.ts"). Suite files given on the command line replace
1199
+ * this list. */
1200
+ suites?: string[];
1201
+ /**
1202
+ * Per-suite `preload`/`bunFlags`, so one tier (e.g. DOM-dependent suites)
1203
+ * can pay for a setup the others don't need. The first project whose
1204
+ * `suites` match a file wins; a file no project matches gets the top-level
1205
+ * `preload`/`bunFlags`. `--preload` / `--bun-flags` replace the matching
1206
+ * field for every file. */
1207
+ projects?: BenchProject[];
1208
+ preload?: string[];
1209
+ /**
1210
+ * Extra flags for the `bun` process that runs each suite file; see
1211
+ * `BenchOptions.bunFlags`. `--bun-flags` replaces this list. */
1212
+ bunFlags?: string[];
1213
+ jobs?: number | "auto";
1214
+ budgetMs?: number;
1215
+ samples?: number;
1216
+ minSamples?: number;
1217
+ gc?: boolean;
1218
+ cpu?: boolean;
1219
+ cpuIntervalUs?: number;
1220
+ alloc?: boolean;
1221
+ peakMem?: boolean;
1222
+ filter?: string;
1223
+ isolate?: boolean;
1224
+ outDir?: string;
1225
+ /**
1226
+ * Kills a suite file's (or isolated task's) subprocess after this many
1227
+ * ms; overrides `ostia ci`'s 10-minute default. */
1228
+ timeoutMs?: number;
1229
+ }
1230
+ export type OstiaConfigInput = Omit<Partial<OstiaConfig>, "thresholds"> & {
1231
+ thresholds?: Partial<Thresholds>;
1232
+ };
1233
+ /**
1234
+ * Builds a document from workloads and their measurements, stamped with
1235
+ * versions, platform, timestamp and git metadata.
1236
+ */
1070
1237
  export declare function createDocument(workloads: Workload[], measurements: Measurement[], environment?: Environment): ProfileDocument;
1071
-
1072
- export declare function saveDocument(doc: ProfileDocument, path: string): Promise<void>;
1073
-
1238
+ /**
1239
+ * Reads a document `saveDocument` wrote; throws `OstiaDocumentError`
1240
+ * unless it's valid JSON with `schemaVersion: 2`.
1241
+ */
1242
+ export declare function loadDocument(path: string): Promise<ProfileDocument>;
1243
+ /**
1244
+ * What `loadDocument` throws for a file that isn't JSON, isn't a document,
1245
+ * or has a `schemaVersion` this ostia doesn't read.
1246
+ */
1074
1247
  export declare class OstiaDocumentError extends Error {
1075
1248
  readonly code: "invalid-json" | "not-a-document" | "unsupported-schema";
1076
1249
  readonly path?: string;
@@ -1080,115 +1253,115 @@ export declare class OstiaDocumentError extends Error {
1080
1253
  schemaVersion?: unknown;
1081
1254
  });
1082
1255
  }
1083
-
1084
- export declare function loadDocument(path: string): Promise<ProfileDocument>;
1085
-
1256
+ /**
1257
+ * Writes a document to `path` atomically: a killed process never leaves a
1258
+ * truncated file.
1259
+ */
1260
+ export declare function saveDocument(doc: ProfileDocument, path: string): Promise<void>;
1261
+ /** Pins `value` against dead-code elimination for an intermediate inside a
1262
+ * task body. A task's own return value is already pinned by the timing
1263
+ * loop. */
1264
+ export declare function keep(value: unknown): void;
1086
1265
  export interface ProfileOptions {
1087
- /** Sampling interval in µs; default 1000. Named like `time()`'s and
1266
+ /**
1267
+ * Sampling interval in µs; default 1000. Named like `time()`'s and
1088
1268
  * `bench()`'s option, the config key and `--cpu-interval`. */
1089
1269
  cpuIntervalUs?: number;
1090
- /** Names the workload: it becomes the label and, instead of the function's
1270
+ /**
1271
+ * Names the workload: it becomes the label and, instead of the function's
1091
1272
  * name and source, what the id hashes, so closures that differ only in
1092
- * captured values get distinct ids and the id survives editing the function. */
1273
+ * captured values get distinct ids and the id survives editing the
1274
+ * function. */
1093
1275
  name?: string;
1094
- /** `"inspector"` (default) captures through CDP and writes a portable
1095
- * .cpuprofile; `"jsc"` uses `bun:jsc.profile` and adds LLInt/Baseline/DFG/FTL
1096
- * tier data. */
1276
+ /**
1277
+ * `"inspector"` (default) captures through CDP and writes a portable
1278
+ * .cpuprofile; `"jsc"` uses `bun:jsc.profile` and adds
1279
+ * LLInt/Baseline/DFG/FTL tier data. */
1097
1280
  origin?: "inspector" | "jsc";
1098
- /** There's no child to kill, so an already-aborted signal skips the profiler,
1099
- * calls `fn` plain (still returning its `result`) and records an `aborted`
1100
- * warning instead of CPU evidence. It can't interrupt a running `fn`. */
1281
+ /**
1282
+ * There's no child to kill, so an already-aborted signal skips the
1283
+ * profiler, calls `fn` plain (still returning its `result`) and records an
1284
+ * `aborted` warning instead of CPU evidence. It can't interrupt a running
1285
+ * `fn`. */
1101
1286
  signal?: AbortSignal;
1102
1287
  }
1103
-
1104
1288
  export interface ProfileResult<T> {
1105
1289
  result: T;
1106
1290
  measurement: Measurement;
1107
1291
  document: ProfileDocument;
1108
1292
  }
1109
-
1293
+ /** Captures a CPU profile of `fn` in the current process. */
1110
1294
  export declare function profile<T>(fn: () => T | Promise<T>, opts?: ProfileOptions): Promise<ProfileResult<T>>;
1111
-
1295
+ /** Each format's renderer, typed with its own options. `Renderer<never>` is
1296
+ * the top type, so `satisfies` checks every format is present without
1297
+ * widening the options. */
1112
1298
  export declare const renderers: {
1113
- table: Renderer<unknown>;
1114
- json: Renderer<unknown>;
1115
- markdown: Renderer<unknown>;
1116
- jsonl: Renderer<unknown>;
1299
+ table: Renderer;
1300
+ json: Renderer;
1301
+ markdown: Renderer;
1302
+ jsonl: Renderer;
1117
1303
  minimal: Renderer<MinimalRenderOptions>;
1118
1304
  collapsed: Renderer<VizOptions>;
1119
1305
  mermaid: Renderer<MermaidOptions>;
1120
1306
  speedscope: Renderer<VizOptions>;
1121
1307
  cpuprofile: Renderer<VizOptions>;
1122
1308
  };
1123
-
1124
- export declare const MINIMAL_PROTOCOL_VERSION: 2;
1125
-
1126
- interface MinimalWarning {
1127
- code: string;
1128
- data?: Record<string, unknown>;
1309
+ interface Renderer<O = unknown> {
1310
+ name: FormatName;
1311
+ render(doc: ProfileDocument, options: O): Promise<RenderResult>;
1129
1312
  }
1130
-
1131
- interface MinimalDelta {
1132
- /** The base's median, ns: the row's own `median` is the candidate's. */
1133
- baseMedian?: number;
1134
- medianPct: number;
1135
- meanPct: number;
1136
- verdict: "improved" | "regressed" | "unchanged";
1137
- pass: boolean;
1138
- /** 95% bootstrap CI on the difference of medians; absent (with `pValue`)
1139
- * on a thin (<5 samples/side) comparison. */
1140
- ci95?: [number, number];
1141
- pValue?: number;
1142
- /** The threshold actually tested against, after machine noise widened it. */
1143
- effectiveTimingPct: number;
1144
- matched: true;
1145
- /** The base task's name, when it was matched through an alias. */
1146
- renamedFrom?: string;
1313
+ interface RenderResult {
1314
+ text?: string;
1315
+ files?: {
1316
+ path?: string;
1317
+ content: string;
1318
+ }[];
1147
1319
  }
1148
-
1149
- interface MinimalPaired {
1150
- /** Base side's median per-call time, ns. */
1151
- baseMedian: number;
1152
- medianRatio: number;
1153
- ratioP25: number;
1154
- ratioP75: number;
1155
- rounds: number;
1156
- /** `flagged` when fresh processes confirmed it, else `"unchanged"`. */
1157
- verdict: "regressed" | "improved" | "unchanged";
1158
- /** What the first process saw, before confirmation. */
1159
- flagged?: "regressed" | "improved";
1160
- confirmed?: boolean;
1161
- /** Median ratio of each fresh-process repeat, by the summary's `metric`. */
1162
- repeats?: number[];
1163
- /** Where the machine counts them: the base's median instructions per call
1164
- * and the candidate/base instruction ratios. */
1165
- instructions?: {
1166
- baseMedian: number;
1167
- medianRatio: number;
1168
- ratioP25: number;
1169
- ratioP75: number;
1320
+ export interface MinimalRenderOptions {
1321
+ protocol?: MinimalProtocolContext;
1322
+ }
1323
+ /**
1324
+ * What the `unmatched`/`summary` events need beyond one `ProfileDocument`.
1325
+ * The CLI builds it for `compare`/`ci`/`ab`; without it `minimal` emits
1326
+ * only `run` lines. `exitCode` is inline because the CLI decides it after
1327
+ * rendering. */
1328
+ export interface MinimalProtocolContext {
1329
+ command: "compare" | "ci" | "ab";
1330
+ exitCode: number;
1331
+ unmatched?: {
1332
+ baseOnly: Workload[];
1333
+ candOnly: Workload[];
1170
1334
  };
1171
- sameOutput: boolean;
1172
- /** The suite file differs from the base's copy. */
1173
- suiteChanged?: true;
1174
- /** `--alloc`: retained heap per call on each side. */
1175
- retained?: MinimalMemoryChange;
1176
- /** `--peak-mem`: first-call RSS rise on each side. */
1177
- peak?: MinimalMemoryChange;
1335
+ baseGit?: GitMetadata;
1336
+ candGit?: GitMetadata;
1337
+ baseline?: {
1338
+ name: string;
1339
+ path: string;
1340
+ };
1341
+ cached?: number;
1342
+ executed?: number;
1343
+ failed?: number;
1344
+ missingBaseline?: number;
1345
+ exportedTo?: string;
1178
1346
  }
1179
-
1180
- interface MinimalMemoryChange {
1181
- base: number;
1182
- cand: number;
1183
- verdict: "regressed" | "improved" | "unchanged";
1184
- floor: number;
1347
+ export interface VizOptions {
1348
+ /** Render this measurement only, instead of every CPU measurement. */
1349
+ measurementId?: string;
1185
1350
  }
1186
-
1351
+ export interface MermaidOptions extends VizOptions {
1352
+ topN?: number;
1353
+ }
1354
+ /** One parsed line of `--format minimal` output; narrow on `event`. */
1355
+ export type MinimalEvent = MinimalRunLine | MinimalUnmatchedLine | MinimalSummaryLine;
1356
+ /**
1357
+ * One per timing run, for piping into an agent's context in place of the
1358
+ * full `ProfileDocument`. Numbers stay in the IR's units (ns). */
1187
1359
  interface MinimalRunLine {
1188
1360
  event: "run";
1189
1361
  protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
1190
1362
  schemaVersion: ProfileDocument["schemaVersion"];
1191
- /** Join key to `Workload.id` / `Comparison.candidateMeasurementId`; unlike
1363
+ /**
1364
+ * Join key to `Workload.id` / `Comparison.candidateMeasurementId`; unlike
1192
1365
  * `task`, stable across invocations. */
1193
1366
  workloadId: string;
1194
1367
  task: string;
@@ -1196,10 +1369,14 @@ interface MinimalRunLine {
1196
1369
  description?: string;
1197
1370
  groupDescription?: string;
1198
1371
  params?: Record<string, string | number | boolean>;
1199
- /** `task.skip()` / `group.skip()`: no measurement, so every stats field is absent. */
1372
+ /**
1373
+ * `task.skip()` / `group.skip()`: no measurement, so every stats field is
1374
+ * absent.
1375
+ */
1200
1376
  skipped?: true;
1201
1377
  unit?: "ns";
1202
- /** 0, with every stats field absent, when no trial produced a sample (all
1378
+ /**
1379
+ * 0, with every stats field absent, when no trial produced a sample (all
1203
1380
  * timed out or missed the `timeSource` pattern); see `warnings`. */
1204
1381
  samples?: number;
1205
1382
  /** In-process trials batched into one timed block; 1 when never batched. */
@@ -1221,21 +1398,25 @@ interface MinimalRunLine {
1221
1398
  retainedBytesPerOp?: number;
1222
1399
  /** `--peak-mem`: how far the task's first call raised RSS, bytes. */
1223
1400
  peakBytes?: number;
1224
- /** In-process tasks, where the machine counts them: median instructions
1401
+ /**
1402
+ * In-process tasks, where the machine counts them: median instructions
1225
1403
  * retired per call (`ab`: the candidate's). */
1226
1404
  instructions?: number;
1227
- /** Median over the group's reference median (its baseline task, else its
1405
+ /**
1406
+ * Median over the group's reference median (its baseline task, else its
1228
1407
  * fastest); only when the document has more than one timing run. */
1229
1408
  relative?: number;
1230
1409
  baseline?: true;
1231
- /** The machine's noise floor from `document.environment`; absent when the
1410
+ /**
1411
+ * The machine's noise floor from `document.environment`; absent when the
1232
1412
  * noise check was skipped. */
1233
1413
  noiseFloorPct?: number;
1234
1414
  warnings: MinimalWarning[];
1235
1415
  /** The change against the baseline document (`compare` / `ci`). */
1236
1416
  delta?: MinimalDelta;
1237
1417
  paired?: MinimalPaired;
1238
- /** `ab` only, instead of stats and `paired`: the task threw on one side
1418
+ /**
1419
+ * `ab` only, instead of stats and `paired`: the task threw on one side
1239
1420
  * (`"base"`/`"cand"`) or both, so it isn't judged on time. `message` is
1240
1421
  * the error's first lines; `repeat` (from 1) is set when it threw in a
1241
1422
  * confirmation repeat. */
@@ -1245,7 +1426,75 @@ interface MinimalRunLine {
1245
1426
  repeat?: number;
1246
1427
  };
1247
1428
  }
1248
-
1429
+ /**
1430
+ * Bumped only on a breaking change to the event shapes (a key renamed or
1431
+ * removed); new keys are additive. Every line carries it. */
1432
+ export declare const MINIMAL_PROTOCOL_VERSION: 2;
1433
+ interface MinimalWarning {
1434
+ code: string;
1435
+ data?: Record<string, unknown>;
1436
+ }
1437
+ interface MinimalDelta {
1438
+ /** The base's median, ns: the row's own `median` is the candidate's. */
1439
+ baseMedian?: number;
1440
+ medianPct: number;
1441
+ meanPct: number;
1442
+ verdict: "improved" | "regressed" | "unchanged";
1443
+ pass: boolean;
1444
+ /**
1445
+ * 95% bootstrap CI on the difference of medians; absent (with `pValue`)
1446
+ * on a thin (<5 samples/side) comparison. */
1447
+ ci95?: [number, number];
1448
+ pValue?: number;
1449
+ /** The threshold actually tested against, after machine noise widened it. */
1450
+ effectiveTimingPct: number;
1451
+ matched: true;
1452
+ /** The base task's name, when it was matched through an alias. */
1453
+ renamedFrom?: string;
1454
+ }
1455
+ /**
1456
+ * `ab` only: the base side and per-round candidate/base ratios behind a
1457
+ * `run` line whose stats are the candidate's. Ratios above 1 mean slower.
1458
+ * */
1459
+ interface MinimalPaired {
1460
+ /** Base side's median per-call time, ns. */
1461
+ baseMedian: number;
1462
+ medianRatio: number;
1463
+ ratioP25: number;
1464
+ ratioP75: number;
1465
+ rounds: number;
1466
+ /** `flagged` when fresh processes confirmed it, else `"unchanged"`. */
1467
+ verdict: "regressed" | "improved" | "unchanged";
1468
+ /** What the first process saw, before confirmation. */
1469
+ flagged?: "regressed" | "improved";
1470
+ confirmed?: boolean;
1471
+ /** Median ratio of each fresh-process repeat, by the summary's `metric`. */
1472
+ repeats?: number[];
1473
+ /**
1474
+ * Where the machine counts them: the base's median instructions per call
1475
+ * and the candidate/base instruction ratios. */
1476
+ instructions?: {
1477
+ baseMedian: number;
1478
+ medianRatio: number;
1479
+ ratioP25: number;
1480
+ ratioP75: number;
1481
+ };
1482
+ sameOutput: boolean;
1483
+ /** The suite file differs from the base's copy. */
1484
+ suiteChanged?: true;
1485
+ /** `--alloc`: retained heap per call on each side. */
1486
+ retained?: MinimalMemoryChange;
1487
+ /** `--peak-mem`: first-call RSS rise on each side. */
1488
+ peak?: MinimalMemoryChange;
1489
+ }
1490
+ /** `ab` only: one memory reading on both sides, bytes. */
1491
+ interface MinimalMemoryChange {
1492
+ base: number;
1493
+ cand: number;
1494
+ verdict: "regressed" | "improved" | "unchanged";
1495
+ floor: number;
1496
+ }
1497
+ /** A workload present on only one side of a `compare`/`ci` run. */
1249
1498
  interface MinimalUnmatchedLine {
1250
1499
  event: "unmatched";
1251
1500
  protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
@@ -1253,7 +1502,9 @@ interface MinimalUnmatchedLine {
1253
1502
  task: string;
1254
1503
  side: "base" | "cand";
1255
1504
  }
1256
-
1505
+ /**
1506
+ * The last line of a `compare`/`ci`/`ab` run; never emitted for a bare
1507
+ * `time`/`bench` document. */
1257
1508
  interface MinimalSummaryLine {
1258
1509
  event: "summary";
1259
1510
  protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
@@ -1283,19 +1534,27 @@ interface MinimalSummaryLine {
1283
1534
  ref: string;
1284
1535
  sha: string;
1285
1536
  };
1286
- /** `ab` only: what the verdicts and `geomeanPct` judge, each round's time
1537
+ /**
1538
+ * `ab` only: what the verdicts and `geomeanPct` judge, each round's time
1287
1539
  * or instruction ratio. */
1288
1540
  metric?: "time" | "instructions";
1289
1541
  /** `ab` only: the gate on `geomeanPct`. */
1290
1542
  geomeanThresholdPct?: number;
1291
- /** `ab` only: flagged in the first process but not reproduced; counted in `unchanged`. */
1543
+ /**
1544
+ * `ab` only: flagged in the first process but not reproduced; counted in
1545
+ * `unchanged`.
1546
+ */
1292
1547
  unconfirmed?: number;
1293
- /** `ab` only: workloads whose first call returned different values on the two sides. */
1548
+ /**
1549
+ * `ab` only: workloads whose first call returned different values on the
1550
+ * two sides.
1551
+ */
1294
1552
  outputDiffers?: number;
1295
1553
  notComparable?: number;
1296
1554
  threw?: number;
1297
1555
  newSuites?: string[];
1298
- /** `ab` only, with `--alloc` or `--peak-mem`: tasks whose memory
1556
+ /**
1557
+ * `ab` only, with `--alloc` or `--peak-mem`: tasks whose memory
1299
1558
  * regressed or improved, and the threshold, percent. */
1300
1559
  memory?: {
1301
1560
  thresholdPct: number;
@@ -1307,42 +1566,16 @@ interface MinimalSummaryLine {
1307
1566
  cand?: GitMetadata;
1308
1567
  };
1309
1568
  exportedTo?: string;
1310
- /** `pass` (exit 0), `fail` (exit 1: a regression), else `error` (exit 2, or
1569
+ /**
1570
+ * `pass` (exit 0), `fail` (exit 1: a regression), else `error` (exit 2, or
1311
1571
  * 130 when cancelled): no verdict was reached. */
1312
1572
  verdict: "pass" | "fail" | "error";
1313
1573
  exitCode: number;
1314
1574
  }
1315
-
1316
- export type MinimalEvent = MinimalRunLine | MinimalUnmatchedLine | MinimalSummaryLine;
1317
-
1318
- export interface MinimalProtocolContext {
1319
- command: "compare" | "ci" | "ab";
1320
- exitCode: number;
1321
- unmatched?: {
1322
- baseOnly: Workload[];
1323
- candOnly: Workload[];
1324
- };
1325
- baseGit?: GitMetadata;
1326
- candGit?: GitMetadata;
1327
- baseline?: {
1328
- name: string;
1329
- path: string;
1330
- };
1331
- cached?: number;
1332
- executed?: number;
1333
- failed?: number;
1334
- missingBaseline?: number;
1335
- exportedTo?: string;
1336
- }
1337
-
1338
- export interface MinimalRenderOptions {
1339
- protocol?: MinimalProtocolContext;
1340
- }
1341
-
1342
- export interface MermaidOptions extends VizOptions {
1343
- topN?: number;
1344
- }
1345
-
1575
+ /**
1576
+ * One command for `time()`: a string (whitespace-split, no shell), an argv
1577
+ * array, or an object with per-command settings, which is how one command
1578
+ * becomes several labeled workloads (e.g. warm vs cold `prepare`). */
1346
1579
  export interface CommandSpec {
1347
1580
  command: string | string[];
1348
1581
  label?: string;
@@ -1355,25 +1588,29 @@ export interface CommandSpec {
1355
1588
  /** Overrides `TimeOptions.ignoreExitCodes` for this command. */
1356
1589
  ignoreExitCodes?: number[];
1357
1590
  }
1358
-
1359
1591
  export interface TimeOptions {
1360
1592
  commands: (string | string[] | CommandSpec)[];
1361
- /** Runs unmeasured before every trial (warmup and instrumented included), in
1362
- * `cwd`/`env`: a command spawned and awaited, or a function. */
1593
+ /**
1594
+ * Runs unmeasured before every trial (warmup and instrumented included),
1595
+ * in `cwd`/`env`: a command spawned and awaited, or a function. */
1363
1596
  prepare?: PrepareHook;
1364
- /** Take timing from a number in each command's own output (e.g. a build
1597
+ /**
1598
+ * Take timing from a number in each command's own output (e.g. a build
1365
1599
  * tool's `built in 342ms`) instead of its wall clock. */
1366
1600
  timeSource?: TimeSource;
1367
1601
  /** Exact trial count; when set, `budgetMs` is ignored. */
1368
1602
  samples?: number;
1369
- /** Wall-clock budget for the sampling loop, ms. Default: ~3s when neither
1603
+ /**
1604
+ * Wall-clock budget for the sampling loop, ms. Default: ~3s when neither
1370
1605
  * `samples` nor `budgetMs` is given. */
1371
1606
  budgetMs?: number;
1372
1607
  /** Floor on trials when no exact `samples` is given. */
1373
1608
  minSamples?: number;
1374
1609
  warmup?: number;
1375
- /** Round-robin trials across commands instead of finishing each command
1376
- * first, so drift hits every command equally. Default: true with 2+ commands. */
1610
+ /**
1611
+ * Round-robin trials across commands instead of finishing each command
1612
+ * first, so drift hits every command equally. Default: true with 2+
1613
+ * commands. */
1377
1614
  interleave?: boolean;
1378
1615
  cwd?: string;
1379
1616
  env?: Record<string, string>;
@@ -1381,19 +1618,26 @@ export interface TimeOptions {
1381
1618
  heap?: boolean;
1382
1619
  cpuIntervalUs?: number;
1383
1620
  outDir?: string;
1384
- /** Measure the machine's noise floor first (default true, ~200ms) and stamp
1621
+ /**
1622
+ * Measure the machine's noise floor first (default true, ~200ms) and stamp
1385
1623
  * it on the document as `environment`. */
1386
1624
  noiseCheck?: boolean;
1387
- /** SIGKILLs a trial (or prepare hook) still running after this many ms. No
1625
+ /**
1626
+ * SIGKILLs a trial (or prepare hook) still running after this many ms. No
1388
1627
  * default. A timed-out trial contributes no sample. */
1389
1628
  timeoutMs?: number;
1390
- /** Abort kills in-flight trials, schedules no more, and resolves (never
1391
- * rejects) with the completed measurements plus an `aborted` warning on the
1392
- * last one. */
1629
+ /**
1630
+ * Abort kills in-flight trials, schedules no more, and resolves (never
1631
+ * rejects) with the completed measurements plus an `aborted` warning on
1632
+ * the last one. */
1393
1633
  signal?: AbortSignal;
1394
- /** Exit codes to treat as success (hyperfine's `--ignore-failure`): the
1395
- * trial still contributes its sample and gets no `nonzero-exit` warning. */
1634
+ /**
1635
+ * Exit codes to treat as success (hyperfine's `--ignore-failure`): the
1636
+ * trial still contributes its sample and gets no `nonzero-exit` warning.
1637
+ * */
1396
1638
  ignoreExitCodes?: number[];
1397
1639
  }
1398
-
1640
+ /** Times each of `commands` as a subprocess, as `ostia time` does. */
1399
1641
  export declare function time(opts: TimeOptions): Promise<ProfileDocument>;
1642
+ /** Identity function that types an `ostia.config.ts` default export. */
1643
+ export declare function defineConfig(config: OstiaConfigInput): OstiaConfigInput;