SYSTEM Cited by 1 source
criterion (Rust)¶
criterion (crates.io/crates/criterion) is the de-facto Rust statistical benchmarking crate. It measures isolated per-function runtime down to the nanosecond by aggregating many repeated executions, builds a statistical model around the timings, and tracks regression / improvement across runs.
Key properties¶
- Nanosecond-resolution timings.
- Statistical summaries (mean, median, outliers, confidence intervals) — not a single point estimate.
- Regression tracking over time — changes in a function's performance are surfaced against a baseline, making commit-to-commit perf wins / regressions obvious.
- No code instrumentation required beyond the
#[bench]- style test harness.
Role in the wiki¶
The canonical wiki instance is Cloudflare's
pingora-origin team using criterion to benchmark successive
implementations of clear_internal_headers (loop → HashMap →
BTreeSet/FST → regex → radix_trie → trie-hard) and pick the
one that won — 3.65 µs → 0.93 µs. Critically the criterion
microbench predictions matched production stack-trace sampling
within a fraction of a percent, validating criterion as a
trustworthy decision substrate for Cloudflare's hot-path work.
Seen in¶
- sources/2024-09-10-cloudflare-a-good-day-to-trie-hard — criterion is the measurement substrate for every data-structure comparison in the post; the "predicted CPU %" column in the production-comparison table extrapolates linearly from the criterion numbers.
Related¶
- systems/pingora-origin — user of criterion for per-function perf work.
- patterns/measurement-driven-micro-optimization — the engineering discipline criterion enables.
- patterns/custom-benchmarking-harness — the complementary pattern when you need a workload-level benchmark, not a per-function one (Figma's Go OpenSearch harness).