SimpleBench
A minimalist microbenchmarking framework for Rust with clear regression detection.
SimpleBench provides a simple #[bench] attribute and automatic workspace-wide benchmark discovery, without the complexity of larger frameworks.
Features
- Simple API - Just add
#[bench]to any function - Workspace support - Automatically discovers and runs benchmarks across all crates
- Regression detection - Statistical comparison against baselines with configurable thresholds
- Low variance - CPU pinning, warmup phases, and high sample counts for reliable measurements
- CI-ready -
--ciflag returns non-zero exit code on regressions - Historical tracking - Stores run history for trend analysis
Quick Start
Installation
Add Dependencies
In your crate's Cargo.toml:
[]
= "1.0.6"
= "1.0.6"
Write a Benchmark
Run Benchmarks
Configuration
Command Line Options
)
)
)
)
)
Environment Variables
All options can also be set via environment variables:
SIMPLEBENCH_SAMPLESSIMPLEBENCH_ITERATIONSSIMPLEBENCH_WARMUP_DURATIONSIMPLEBENCH_THRESHOLDSIMPLEBENCH_BENCH_FILTER
Configuration File
Create .simplebench.toml in your project root:
[]
= 1000
= 1000
= 5
[]
= 5.0
CI Integration
# .github/workflows/bench.yml
name: Benchmarks
on:
jobs:
bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-simplebench
- run: cargo simplebench --ci
Subcommands
# Run benchmarks
# Clean baseline data
# Analyze historical trends
How It Works
SimpleBench uses the inventory crate for compile-time benchmark registration. The #[bench] macro expands to register each benchmark function, and cargo simplebench builds a unified runner that links all workspace crates and executes discovered benchmarks.
Benchmarks are compiled with #[cfg(test)], so they're excluded from production builds.
Crates
cargo-simplebench- CLI toolsimplebench-runtime- Core runtime librarysimplebench-macros-#[bench]proc-macro
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
This project was co-authored with Claude, an AI assistant by Anthropic.