Expand description
SimpleBench Runtime - Core library for the SimpleBench microbenchmarking framework.
This crate provides the runtime components for SimpleBench:
- Benchmark registration via the
SimpleBenchstruct andinventorycrate - Timing and measurement with warmup phases
- Statistical analysis of benchmark results
- Baseline storage and regression detection
§Usage
This crate is typically used alongside simplebench-macros which provides the
#[bench] attribute for easy benchmark registration:
ⓘ
use simplebench_macros::bench;
// Simple benchmark - measures single function calls
#[bench]
fn my_benchmark() {
// code to benchmark
}
// Setup runs once, benchmark receives reference
#[bench(setup = create_data)]
fn benchmark_with_setup(data: &Data) {
process(data);
}
// Setup runs before each sample - for mutations/consumption
#[bench(setup_each = || vec![3, 1, 4, 1, 5])]
fn bench_sort(mut data: Vec<i32>) {
data.sort();
}The cargo simplebench CLI tool handles compilation and execution of benchmarks.
Re-exports§
pub use inventory;pub use baseline::*;pub use changepoint::*;pub use config::*;pub use cpu_analysis::*;pub use cpu_monitor::*;pub use measurement::*;pub use output::*;pub use progress::*;pub use statistics::*;
Modules§
- baseline
- changepoint
- Bayesian Online Change Point Detection
- config
- cpu_
analysis - CPU analysis for detecting thermal throttling, frequency variance, and cold starts
- cpu_
monitor - CPU monitoring for Linux systems
- measurement
- output
- progress
- Progress reporting for benchmark execution.
- statistics
- Statistical functions for baseline comparison and regression detection
Structs§
- Bench
Result - Complete result of a benchmark run.
- Benchmark
Info - Benchmark metadata for JSON listing.
- Comparison
- Comparison between current benchmark run and baseline.
- Percentiles
- Percentile statistics for a benchmark run.
- Simple
Bench - A registered benchmark function.
- Statistics
- Comprehensive statistics for a benchmark run.
Functions§
- calculate_
statistics - Calculate comprehensive statistics from raw timing samples
- list_
benchmarks_ json - List all registered benchmarks as JSON to stdout
- run_
and_ stream_ benchmarks - Run all benchmarks with configuration and stream results
- run_
single_ benchmark_ json - Run a single benchmark and output JSON result to stdout