Reference
measure measure(1)
Discover and run TypeScript benchmark, latency, and timing files.
Name
measure — discover and run TypeScript benchmark, latency, and timing files
Synopsis
measure [-c path] [--mode quick|standard|rigorous] [--include pattern]… [--exclude pattern]… [--filter pattern]… [--reporter type]… [--baseline name|path]… [--runtime id]… [option]…measure gate [-c path] [--baseline name|path]… [option]… archives…measure runtimes [-c path]Description
measure discovers every bench file, registers each condition and case before anything is measured, then runs every fork unit in fresh processes — or fresh browsers — under a measurement plan, pools the executions, decides the gates and hands the results to the reporters.
Every option resolves in the same order: command-line flag, then config file, then default. The engine underneath is runBench, which takes those already resolved: use it to run benchmarks from your own code instead of a config file.
Options
Selecting what runs
-c, --config path#Path to bench config file.
Without -c no config is read and every default applies. The default export is validated when loaded: an unknown or ill-typed field is reported by its path (gates.0.denominators: …) and measure exits 4 before anything starts.
Glob pattern for bench files (repeatable)
Default **/*.bench.ts. Paths are recorded relative to the working directory, /-separated, so results from two checkouts compare.
Glob pattern to exclude (repeatable)
Default node_modules/**.
Only run conditions/cases whose title/name contains this substring (repeatable)
A case is kept when its condition titles or its name contain one of the substrings. A gate whose subject was filtered out reads skipped.
--list#List discovered conditions and cases without running them.
Alias for --list.
How much to measure
--mode mode#How much rigour to apply: quick, standard or rigorous.
An intent, not a plan: how many processes a trustworthy answer takes is decided for you. quick measures once and implies --allow-inconclusive; standard starts with two processes and buys more only for a gate left open; rigorous adds isolated runs, a cool-down and a retry.
| mode | processes | isolated | rounds | cool-down | retries |
|---|---|---|---|---|---|
quick | 1–1 | 0 | 1 | no | 0 |
standard default | 2–5 | 0 | 16 | no | 0 |
rigorous | 5–9 | 3 | 16 | yes | 1 |
Measure in this runtime: "node", or a runtime plugin's id from the config (repeatable; overrides the config's runtimes)
chromium, firefox and webkit come from @ac-bench/browser, listed in plugins. Runtimes run one after another, in the order given.
--headed#Show the browsers of browser runtimes (debugging; recorded in the archive)
--order-seed n#Reproduce a run's replicate and case ordering exactly.
--max-total-time ms#Stop the run after this many milliseconds, retries and cooldown included.
--profile caseKey#Re-run one case ("condition > … > case") alone under the CPU profiler and attach its profile, measuring nothing.
The profile (<case>.cpuprofile) is attached to the run; run-json keeps it, and Chrome DevTools or VS Code open it. The profiler perturbs what it observes, so nothing is measured or gated in that run.
Gates and baselines
--allow-inconclusive#Exit 0 instead of 2 when a gate is undecided (implied by --mode quick)
Compare with a recorded run: a name filed for this environment, or a path (repeatable)
A name is looked up under this run's own fingerprint, so it never reaches another machine's baseline by accident; a value containing / or ending in .json is a path. Several baselines pool as more executions.
--save-baseline name|path#Record this run as a baseline: a name filed under this environment's fingerprint, or a path.
Files the archive under <baseline.directory>/<fingerprint>/<name>.json.
--max-regression fraction#Fail a case slower than its baseline by more than this fraction (0.03 is 3 %)
Without a baseline gate in the config, every case present in both runs gets one: now / baseline ≤ 1 + fraction. Without a threshold the comparison is only reported.
--allow-foreign-baseline#Compare with another environment's baseline, through the config's baseline.normalizeBy.
Compares the double ratio (case / normalizer) now ÷ (case / normalizer) then, which cancels machine speed to first order. Without it a foreign baseline is incomparable (exit 4).
Output
Reporter to use: table, json, markdown, csv, junit, run-json, summary (repeatable)
table, json, markdown, csv and junit are the reporters this CLI ships; run-json and summary come from @ac-kit/app-report. Any other id must name a reporter plugin listed in the config's plugins, which configures it without selecting it.
--output path#Output base name for file reporters.
Each file reporter adds its extension: bench-results.json, .md, .csv, .junit.xml, .gates.csv, .run.json. Default bench-results.
--emit-samples#Attach every case's raw samples; they are copied across the process boundary.
--verbose#Show every benchmark child's output as it happens, and full stack traces.
Information
Commands
measure gate- Evaluate the gates of recorded archives: pools them as more executions, prints the gates table and exits with the verdicts' code.
measure runtimes- Check every configured runtime: what is installed, whether it launches, and the remedy of each problem.
Configuration
The file passed with -c default-exports defineConfig({ … }). Every key is optional; bench.config(5) has each one in full.
| key | type | meaning |
|---|---|---|
include | string[] | Glob patterns for bench files. |
exclude | string[] | Glob patterns to exclude. |
reporters | string[] | Ids of the reporters to run, in output order. |
output | string | Default output base name (without extension) for file reporters. |
sampling | record | Default sampling options per measure id, under each condition's own: { duration: { minRuns: 20, maxTimeMs: 5000 }, resource: { warmup: 5 } }. |
plugins | plugin[] | Measure, reporter and runtime plugins available to this run. |
runtimes | string[] | Ids of the runtimes to measure in, one after another in this order. |
setupFiles | string[] | Modules imported inside every child before the bench file, in order. |
heartbeatTimeoutMs | integer > 0 | Time without any message from a child before it is considered stuck. |
conditionTimeoutMs | integer ≥ 0 | Wall-clock cap on one fork unit. |
maxTotalTimeMs | integer ≥ 0 | Wall-clock cap on the whole run, retries and cooldown included. |
mode | "quick" | "standard" | "rigorous" | How much rigour to apply. |
measurementPlan | object | Pins individual measurement-plan parameters, overriding what mode derives. |
orderSeed | integer | Seeds replicate and case ordering. |
gates | object[] | Gates that span suites, apply to many suites at once, or belong to the run rather than the code. |
gate | object | The gates' statistics and escalation (confidence, multiplicity, …). |
baseline | object | How the run records and compares with baselines. |
Environment
NO_COLOR,FORCE_COLOR,NODE_DISABLE_COLORS- Read through Node's colour depth: whether the table reporter colours its rows. A stream that is not a terminal is never coloured.
PLAYWRIGHT_BROWSERS_PATH- Where
@ac-bench/browser's runtimes andmeasure runtimeslook for browser builds. AC_BENCH_RUN_ID,AC_BENCH_ARTIFACT_CACHE_ROOT- Set by
measurein every child, for a suite or a fixture that caches build artefacts per run.
Exit status
| status | name | meaning |
|---|---|---|
0 | success | Every gate passed or reported; nothing failed to measure. |
1 | gateFailed | At least one gate failed: a threshold exceeded beyond the measured spread. |
2 | inconclusive | No failure, at least one gate undecided. allowInconclusive turns this into 0. |
3 | measurementError | A case, condition or child failed, a file did not load, a runtime could not start, or a gate's subject is missing. |
4 | usageError | Invalid flag, config or gate declaration; unknown runtime; incomparable baseline. |
5 | nothingRan | Nothing matched: no file, or every case filtered out. |
130 | interrupted | SIGINT. |
When several apply, the most serious wins: 130, then 4, then 3, then 1, then 2, then 5, then 0.
Files
**/*.bench.ts- Bench files, unless
--includeorincludesays otherwise. TypeScript is loaded by@ac-bench/lib/register. bench-results.*- File reporters' output, named by
--output:.json(the archive),.md,.csv,.gates.csv,.junit.xml,.run.json. node_modules/.cache/ac-bench/baselines/fingerprint/name.json- Baselines saved by name; the directory is
baseline.directory. case.cpuprofile- The profile
--profileattaches to the run.
Examples
measure -c bench.config.ts --list --filter vec3measure -c bench.config.ts --mode quick --runtime node --runtime chromiummeasure -c bench.config.ts --save-baseline mainmeasure -c bench.config.ts --baseline main --max-regression 0.03
measure -c bench.config.ts --reporter table --reporter junit --output bench