codspeed-criterion-compat

Drop-in Criterion.rs compatibility layer that runs Rust benchmarks under CodSpeed.

Library
Cargo
v5.0.1
70stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
71/100Good
Development Activity80
Maintenance84
Community48
Maturity52
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality84
Innovation80
Learning Curve85

codspeed-criterion-compat is a compatibility layer that lets existing Criterion.rs benchmark suites run under CodSpeed, a continuous benchmarking platform. You add it as a dev-dependency renamed to criterion, keep your existing benchmark code and imports, and the crate transparently swaps in CodSpeed’s instrumented measurement when running in CodSpeed’s environment while behaving like normal Criterion.rs otherwise.

Because it mirrors Criterion’s public API, adopting it requires essentially no changes to your benchmarks. In CI, CodSpeed uses instrumentation to produce stable, low-variance measurements that catch performance regressions on every pull request, and this crate is the bridge that makes that possible for projects already using Criterion.

What You Get

  • A drop-in replacement for the criterion crate with the same macros and types
  • CodSpeed instrumentation for stable, low-variance benchmark measurements in CI
  • Zero-change adoption: keep existing benchmark code by renaming the dependency to criterion
  • Normal Criterion.rs behavior when not running inside CodSpeed
  • Optional async runtime support (Tokio, smol, futures) matching Criterion’s async features

Common Use Cases

  • Adding continuous benchmarking to a Rust project that already uses Criterion.rs
  • Detecting performance regressions on every pull request in CI
  • Running the same benchmark suite locally with Criterion and in CI with CodSpeed
  • Tracking benchmark trends for a library over time on the CodSpeed platform

Under The Hood

Architecture - The crate lives in crates/criterion_compat of the codspeed-rust workspace and layers over a vendored Criterion fork (criterion_fork, published as codspeed-criterion-compat-walltime). It re-exports Criterion’s public surface and, via the core codspeed crate, switches measurement to CodSpeed instrumentation when the CodSpeed runtime is detected; otherwise it falls through to the standard wall-time Criterion path.

Tech Stack - Written in Rust (edition 2021, MSRV 1.85) as a Cargo workspace member. It depends on the internal codspeed crate and Criterion fork plus clap, regex, and colored, with optional tokio, smol, and futures features for async benchmarks. Sibling crates cover Divan and Bencher and the cargo-codspeed command-line runner.

Code Quality - The workspace is dual-licensed, uses a pinned rust-toolchain.toml, ships CI workflows and example benchmarks (including a divan_compat examples crate), and is actively and consistently maintained. Keeping the Criterion fork as a workspace member lets the team track upstream while layering instrumentation cleanly.

API Design - The defining design choice is API-for-API compatibility with Criterion.rs: the recommended install renames the dependency to criterion, so existing imports, criterion_group!, and criterion_main! continue to work untouched. This makes the on-ramp to continuous benchmarking essentially frictionless for Criterion users.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search