OptionalconcurrencyExecutes tasks concurrently based on the specified concurrency mode.
mode is set to null (default), concurrency is disabled.mode is set to 'task', each task's iterations (calls of a task function) run concurrently.mode is set to 'bench', different tasks within the bench run concurrently.The number of times that a task should run if even the time option is finished.
OptionalnameBenchmark name.
Function to get the current timestamp in milliseconds.
OptionalretainKeep samples for statistics calculation
Setup function to run before each benchmark task (cycle)
OptionalsignalAn AbortSignal for aborting the benchmark.
Whether to subtract an estimated timestamp provider call overhead from each raw latency sample.
Each sample is measured as t1 - t0 around a single call to the task
function, so every raw sample is inflated by approximately one
timestamp provider call cost C. When this option is true, an
estimate Ĉ is computed once at construction time via
calibrateTimerOverhead, and max(0, raw_sample - Ĉ) is used
in place of each non-overridden sample before statistics are computed.
Statistics after correction. All fields of Statistics are
derived from the clamped corrected samples, not from the raw
distribution. With M denoting the raw-sample mean:
X >> Ĉ). The clamp max(0, …) rarely
triggers, so the correction acts as a translation by Ĉ. Location
statistics (mean, min, max, all percentiles) decrease by Ĉ;
absolute-unit dispersion (vr, sd, sem, moe, mad, aad)
is essentially unchanged. Because rme = moe / mean, it inflates
by the deterministic factor M / (M − Ĉ) whenever Ĉ > 0.X ≈ Ĉ). A non-trivial fraction of
samples clamp to 0, biasing the corrected mean upward,
contracting vr/sd/sem/moe/aad, and compounding the
M / (M − Ĉ) factor in rme. Once the cumulative mass of raw
samples at or below Ĉ reaches a given quantile, that percentile
collapses to 0; in particular p50 collapses once at least half
of the raw samples satisfy raw_sample ≤ Ĉ, which then forces
mad and aad toward 0. Prefer overriddenDuration for
sub-overhead measurements.Three observable consequences of the clamp.
latency.min may be exactly 0 even when no zero-duration sample
was actually observed.1000 / latency.mean (or 0
when mean === 0) for every clamped sample.'zero-dominated' cannot
distinguish clamped samples from genuine zero-duration timer
reads, so a 'warning' event may be dispatched in the
sub-overhead regime even when the timer itself is not saturated.Caveat — concurrency: "task". The overhead is calibrated once
at construction time with sequential timer calls. Setting both
options causes the constructor (and run()) to throw, since the
sequentially-calibrated estimate would not reflect the per-iteration
timer call cost under concurrent execution.
Caveat — overriddenDuration. Samples returned by the task
function via overriddenDuration are intentional user values and
are never modified by the correction. They are also excluded from
Task.detectedResolution and from timer-saturation detection.
On runtimes with a coarse timer (resolution >= 1 ms), the
calibration returns 0 and this option becomes a no-op.
Teardown function to run after each benchmark task (cycle).
OptionalthresholdThe maximum number of concurrent tasks to run
Throws if a task fails.
Time needed for running a benchmark task in milliseconds.
OptionaltimestampThe timestamp provider used by the benchmark. By default 'performance.now' will be used.
Warmup benchmark.
Warmup iterations.
Warmup time in milliseconds.
The resolved benchmark options