ac-bench
Reference

Reference

bench.config.ts bench.config(5)

The configuration file of measure: 17 keys, each generated from the schema that validates it and the TSDoc that explains it.

Name

bench.config.ts — the configuration measure -c reads

Synopsis

bench.config.ts
import { defineConfig } from "@ac-bench/cli";
import durationPlugin from "@ac-bench/measure-duration/plugin";

export default defineConfig({
  plugins: [durationPlugin],
  reporters: ["table", "json"],
  mode: "standard",
  baseline: { maxRegression: 0.03 },
});

Description

A TypeScript or JavaScript module whose default export is the configuration, typed by defineConfig. There is no default file: measure reads one only when -c names it, and otherwise applies every default.

Every key is optional. A command-line flag overrides the key it stands for; the key overrides the default. The export is validated when it is loaded: an unknown or ill-typed field is reported by its path (gates.0.denominators: …) and measure exits 4 before anything starts.

Keys

includestring[]#

Glob patterns for bench files. Default: ["**/*.bench.ts"]

excludestring[]#

Glob patterns to exclude. Default: ["node_modules/**"]

reportersstring[]#

Ids of the reporters to run, in output order. Default: ["table"]. Also settable with --reporter.

"table", "json", "markdown", "csv", "junit", "run-json" and "summary" resolve to the reporters this CLI ships, with their default options; any other id must name a reporter plugin listed in plugins. Listing a reporter in plugins configures it, it does not select it — that way --reporter csv can turn on a reporter this file has already configured.

outputstring#

Default output base name (without extension) for file reporters.

samplingrecord#

Default sampling options per measure id, under each condition’s own: { duration: { minRuns: 20, maxTimeMs: 5000 }, resource: { warmup: 5 } }. Duration and resource read them; a key a measure does not know is ignored.

pluginsplugin[]#

Measure, reporter and runtime plugins available to this run.

Import each package directly and list what it exports: a package that takes options exports a factory (jsonReporter({ output })), one that does not exports the plugin (durationPlugin, tableReporter). The CLI never imports a measure package itself.

runtimesstring[]#

Ids of the runtimes to measure in, one after another in this order. Default: ["node"].

"node" resolves to nodeRuntime() with its default options; any other id must name a runtime plugin listed in plugins, which configures it without selecting it, as for reporters.

setupFilesstring[]#

Modules imported inside every child before the bench file, in order.

beforeAll/afterAll are condition-scoped and nothing wider exists, so this is the only per-child setup mechanism. Its cost is paid once per fork unit rather than once per run — which is what asking for it means when no state crosses a process boundary.

heartbeatTimeoutMsinteger > 0#

Time without any message from a child before it is considered stuck. Default 30_000. Reset by every message it sends.

conditionTimeoutMsinteger ≥ 0#

Wall-clock cap on one fork unit. Default 0, meaning no cap.

maxTotalTimeMsinteger ≥ 0#

Wall-clock cap on the whole run, retries and cooldown included. Default 0, meaning no cap. Also settable with --max-total-time.

mode"quick" | "standard" | "rigorous"#

How much rigour to apply. Default "standard". Also settable with --mode, which is the intended way in.

measurementPlanobject#

Pins individual measurement-plan parameters, overriding what mode derives.

For a run that must reproduce an exact plan rather than express an intent — a published comparison, or a CI job that has to stay comparable with last month’s. Everyone else should use mode.

keytypemeaning
replicatesinteger ≥ 1

P: independent processes running the whole condition, cases together.

Differences between cases measured in the same process are paired, so the process-level offset cancels. Replicating gives that offset a distribution instead of one unknown draw.

maxReplicatesinteger ≥ 1

Ceiling on P when the run escalates.

A plan that starts cheap buys more processes only for a comparison its intervals have not settled, and only up to here.

isolatedRunsinteger ≥ 0

Q: additional processes running one case alone, with the full ancestor hook chain.

The only way to tell “this case is slow” from “this case is slow after the one before it”. Costs an execution of every ancestor hook per case, so it stays small and off by default.

roundsinteger ≥ 1

R: how many turns each case takes within one process.

Above 1 the cases interleave, one measured slice each in turn, so none of them owns a single stretch of the process’s life. At 1 they run to completion one after another, and the first case measured gets the cold interpreter while the last gets the warm one.

cooldownboolean

Wait for the machine to settle before each attempt.

retryOnInstabilityinteger ≥ 0

Re-runs of a condition whose environment verdict was "unstable".

orderSeedinteger#

Seeds replicate and case ordering. Default: derived from the clock, so each run randomises differently. Pin it to reproduce a run exactly.

gatesobject[]#

Gates that span suites, apply to many suites at once, or belong to the run rather than the code. Each reference is a glob per segment; one matching nothing is a usage error (exit 4) before anything is measured.

gateobject#

The gates’ statistics and escalation (confidence, multiplicity, …).

keytypemeaning
confidencenumber > 0 < 1

Two-sided confidence of each interval before multiplicity. Default 0.95.

multiplicity"holm" | "bonferroni" | "none"

Family-wise adjustment over every hypothesis of the run. Default "holm".

pooling"hartung-knapp" | "dersimonian-laird"

Interval across executions. Default "hartung-knapp".

maxDispersionnumber > 0

Upper limit on the combined within-execution dispersion (relative MAD); above it a gate is inconclusive whatever its interval says. Default: none.

minExecutionsinteger ≥ 1

Fewest executions per subject before a gate may be decided. Default 3.

escalateboolean

Buy replicates while a fork unit’s gate is undecided. Default true.

baselineobject#

How the run records and compares with baselines.

keytypemeaning
directorystring

Where --save-baseline <name> files a baseline and --baseline <name> finds one, each under its environment’s fingerprint. Default node_modules/.cache/ac-bench/baselines, never committed.

maxRegressionnumber ≥ 0

Default of --max-regression; absent, a baseline is only compared and reported.

normalizeBystring | object

The case every baseline comparison is divided by, so machine speed cancels: what --allow-foreign-baseline compares through.

Examples

Check a config without measuring
measure -c bench.config.ts --list

See also