benchmark_types.ts

Declarations
#

5 declarations

view source

BenchmarkConfig
#

benchmark_types.ts view source

BenchmarkConfig

Configuration options for a benchmark suite.

duration_ms

Target duration to run each benchmark task in milliseconds. The benchmark will run until this duration is reached or max_iterations is hit. Default: 1000ms

type number

warmup_iterations

Number of warmup iterations before actual measurements. Warmup helps stabilize JIT compilation and caches. Default: 5

type number

cooldown_ms

Cooldown time between tasks in milliseconds. Helps prevent interference between benchmarks. Default: 100ms

type number

min_iterations

Minimum number of iterations to run. Default: 10

type number

max_iterations

Maximum number of iterations to run. Prevents infinite loops if function is extremely fast. Default: 100000

type number

timer

Custom timer to use for measurements. Default: timer_default (auto-detects environment)

type Timer

on_iteration

Callback invoked after each iteration completes. Useful for triggering garbage collection, logging progress, early termination, or custom instrumentation.

Note: The callback time is NOT included in iteration measurements - it runs after the timing capture. However, frequent GC calls will slow overall benchmark execution time.

type (task_name: string, iteration: number, abort: () => void) => void

on_task_complete

Callback invoked after each task completes. Useful for logging progress during long benchmark runs.

type (result: BenchmarkResult, index: number, total: number) => void

BenchmarkFormatTableOptions
#

benchmark_types.ts view source

BenchmarkFormatTableOptions

Options for table formatting.

groups

Group results by category using filter functions.

type Array<BenchmarkGroup>

BenchmarkGroup
#

benchmark_types.ts view source

BenchmarkGroup

A group definition for organizing benchmark results.

name

Display name for the group

type string

description

Optional description shown below the group name

type string

filter

Filter function to determine which results belong to this group

type (result: BenchmarkResult) => boolean

baseline

Task name to use as baseline for the "vs" column. When specified, ratios are computed against this task instead of the fastest. If the baseline task is not found in the group, falls back to "vs Best" with a warning.

type string

BenchmarkResult
#

benchmark_types.ts view source

BenchmarkResult

Result from running a single benchmark task.

name

Task name

type string

stats

Statistical analysis of the benchmark

iterations

Number of iterations executed

type number

total_time_ms

Total time spent benchmarking (including warmup) in milliseconds

type number

timings_ns

Raw timing data for each iteration in nanoseconds. Useful for custom statistical analysis, histogram generation, or exporting to external tools.

type Array<number>

BenchmarkTask
#

benchmark_types.ts view source

BenchmarkTask

A benchmark task to execute.

name

Name of the task (for display)

type string

fn

Function to benchmark (sync or async). Return values are ignored.

type () => unknown

setup

Optional setup function run before benchmarking this task. Not included in timing measurements.

type () => void | Promise<void>

teardown

Optional teardown function run after benchmarking this task. Not included in timing measurements.

type () => void | Promise<void>

skip

If true, skip this task during benchmark runs. Useful for temporarily disabling tasks during development.

type boolean

only

If true, run only this task (and other tasks marked only). Useful for focusing on specific tasks during development.

type boolean

async

Hint for whether the function is sync or async. If not provided, automatically detected during warmup. Setting this explicitly skips per-iteration promise checking for sync functions.

type boolean