bench(name?, options?, fn): Promise
stringname property of fn,
or '<anonymous>' when fn has no name.ObjectArray[].booleanonly set,
benchmarks without only in their hierarchy are skipped. Default:
false.Objectnumbercontext.done(). Default: 30.AbortSignalfalse.string[][].numberInfinity.number0.Function | AsyncFunctionBenchContext.Promiseundefined immediately when declared in a
suite.Warmup invocations use the same callback and timing contract as measured samples, but their samples are discarded. An exception, rejection, timeout, abort, missing timing call, or duplicate timing call stops the current benchmark. Later benchmarks continue to run.
After a timeout or abort, the runner briefly waits for asynchronous benchmark work to settle before continuing. If it remains pending, all later benchmarks that were selected to run fail without running so that their measurements cannot overlap with that work.
For each warmup and measured callback, the runner subscribes to the configured
diagnostics channels. Each publication queues a context diagnostic whose
message is { name, message }, containing the string channel name and the
published message. Subscriptions are removed when the callback settles or is
aborted.
A timeout or abort cannot interrupt synchronous JavaScript and does not forcibly
cancel asynchronous work that ignores context.signal.
The benchId is based on the declaration source file, hierarchical suite and
benchmark names, and canonicalized parameters. It is stable for repeated runs
from the same source location, but the embedded source value is not normalized
across checkout roots, module formats, operating systems, or path casing.
Execution scope is represented separately. A runId identifies one logical
run, while fileRunId identifies a file runner or child execution within that
run. The entryFile field records which entry-file import caused a declaration
and is null for declarations made by preload modules.
The same benchId can therefore occur under multiple fileRunId values when
entry files use a shared declaration helper. Declaring the same benchId more
than once within one file execution scope reports an error rather than merging
the samples.
bench.skip(name?, options?, fn): void
Shorthand for bench(name, { ...options, skip: true }, fn).
bench.only(name?, options?, fn): void
Shorthand for bench(name, { ...options, only: true }, fn).