ac-bench
Reference

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.

--include patternrepeatable#

Glob pattern for bench files (repeatable)

Default **/*.bench.ts. Paths are recorded relative to the working directory, /-separated, so results from two checkouts compare.

--exclude patternrepeatable#

Glob pattern to exclude (repeatable)

Default node_modules/**.

--filter patternrepeatable#

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.

--dry-runalias#

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.

What each mode stands for, from resolveMeasurementPlan
modeprocessesisolatedroundscool-downretries
quick1–101no0
standard default2–5016no0
rigorous5–9316yes1
--runtime idrepeatable#

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)

--baseline name|pathrepeatable#

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 typerepeatable#

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

-V, --version#

output the version number.

-h, --help#

display help for command.

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.

keytypemeaning
includestring[]Glob patterns for bench files.
excludestring[]Glob patterns to exclude.
reportersstring[]Ids of the reporters to run, in output order.
outputstringDefault output base name (without extension) for file reporters.
samplingrecordDefault sampling options per measure id, under each condition's own: { duration: { minRuns: 20, maxTimeMs: 5000 }, resource: { warmup: 5 } }.
pluginsplugin[]Measure, reporter and runtime plugins available to this run.
runtimesstring[]Ids of the runtimes to measure in, one after another in this order.
setupFilesstring[]Modules imported inside every child before the bench file, in order.
heartbeatTimeoutMsinteger > 0Time without any message from a child before it is considered stuck.
conditionTimeoutMsinteger ≥ 0Wall-clock cap on one fork unit.
maxTotalTimeMsinteger ≥ 0Wall-clock cap on the whole run, retries and cooldown included.
mode"quick" | "standard" | "rigorous"How much rigour to apply.
measurementPlanobjectPins individual measurement-plan parameters, overriding what mode derives.
orderSeedintegerSeeds replicate and case ordering.
gatesobject[]Gates that span suites, apply to many suites at once, or belong to the run rather than the code.
gateobjectThe gates' statistics and escalation (confidence, multiplicity, …).
baselineobjectHow 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 and measure runtimes look for browser builds.
AC_BENCH_RUN_ID, AC_BENCH_ARTIFACT_CACHE_ROOT
Set by measure in every child, for a suite or a fixture that caches build artefacts per run.

Exit status

statusnamemeaning
0successEvery gate passed or reported; nothing failed to measure.
1gateFailedAt least one gate failed: a threshold exceeded beyond the measured spread.
2inconclusiveNo failure, at least one gate undecided. allowInconclusive turns this into 0.
3measurementErrorA case, condition or child failed, a file did not load, a runtime could not start, or a gate's subject is missing.
4usageErrorInvalid flag, config or gate declaration; unknown runtime; incomparable baseline.
5nothingRanNothing matched: no file, or every case filtered out.
130interruptedSIGINT.

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 --include or include says 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 --profile attaches to the run.

Examples

List what would run, without measuring
measure -c bench.config.ts --list --filter vec3
A quick look in Node and Chromium
measure -c bench.config.ts --mode quick --runtime node --runtime chromium
Record a baseline, then fail on a 3 % regression
measure -c bench.config.ts --save-baseline mainmeasure -c bench.config.ts --baseline main --max-regression 0.03
CI: a table in the log, JUnit for the merge request
measure -c bench.config.ts --reporter table --reporter junit --output bench

See also