as-bench
as-bench is a runtime-agnostic, statistically-aware benchmarking framework for AssemblyScript.
You write benchmarks once, then run them on the runtime you actually ship to — Node, a standalone WASI runtime like wasmtime, wasmer, or wazero — and get Criterion-style timing with confidence intervals, outlier classification, and baseline comparisons. Your bench file is compiled together with a statistics engine and executed inside WebAssembly, so what you measure is what runs.
It ships as a CLI (asb / as-bench) and an npm dev dependency. The statistics engine runs entirely inside wasm — the host only supplies a clock, settings, and the reporting channel.
What you get
- Benchmarks in
assembly/__benches__/**/*.tswithbench(),suite(), andblackbox(). - Real statistics — adaptive warmup, an auto-sized sampling plan, bootstrap confidence intervals, and Tukey outlier classification, ported from as-tral / Criterion.rs.
- Suite deltas — each bench after the first reports its change versus the suite baseline, with a permutation-test verdict.
- Baselines — save a run, compare against it later, or diff two saved runs in CI.
- Profiling — per-function instruction counts, wall-clock self time, or allocation bytes, all from one
profilecommand. - Any runtime — external WASI runtimes stream results over a framed binary protocol (WIPC); compare several runtimes in one table.
Start here
- Getting Started — install, scaffold, and run your first bench.
- Writing Benchmarks —
bench,suite,blackbox, throughput, and charts. - Statistics & Output — how the numbers are produced and how to read them.
- Baselines — save and compare runs.
- Profiling — find where the time, instructions, or bytes go.
- Runtimes & Modes — run the same benches across runtimes.
- CLI and Configuration — once the defaults stop being enough.
Project layout
A typical project looks like this:
assembly/
__benches__/
example.ts
.as-bench/
build/ compiled wasm artifacts
baselines/ saved baselines (commit these)
charts/ generated SVG charts
as-bench.config.jsonIf you also need fast JSON for the data structures you benchmark, see json-as.
