deno bench: Run Benchmarks in CI
deno bench discovers and runs Deno.bench cases, reporting timings for each.
deno bench is the benchmarking counterpart to deno test. It is built in, runs under the same sandbox, and can emit JSON for tracking over time.
What it does
deno bench finds *_bench.ts and *.bench.ts files, runs each Deno.bench case repeatedly, and reports time per iteration and relative speed. Like tests, benchmarks run under the permission sandbox.
Common usage
deno bench
deno bench --allow-read bench/
deno bench --filter "json parse"
# capture results for tracking
deno bench --json > bench.jsonOptions
| Flag | What it does |
|---|---|
| --json | Emit benchmark results as JSON |
| --filter <pattern> | Run only benchmarks whose name matches |
| --allow-read / --allow-net | Grant permissions to the benchmarks |
| --no-check | Skip type-checking before running |
In CI
Benchmarks are noisy on shared runners, so treat deno bench --json output as a trend rather than a hard gate, and pin the runner type for comparable numbers. Restore DENO_DIR first so dependency downloads do not skew timings.
Common errors in CI
"No bench modules found" means file names did not match the *_bench.ts convention. "Requires read access to ..." means a benchmark touched the filesystem without --allow-read. Wildly inconsistent timings on CI usually reflect a shared, throttled runner rather than a code change.