Crate simplebench_runtime

Crate simplebench_runtime 

Source
Expand description

SimpleBench Runtime - Core library for the SimpleBench microbenchmarking framework.

This crate provides the runtime components for SimpleBench:

  • Benchmark registration via the SimpleBench struct and inventory crate
  • 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§

BenchResult
Complete result of a benchmark run.
BenchmarkInfo
Benchmark metadata for JSON listing.
Comparison
Comparison between current benchmark run and baseline.
Percentiles
Percentile statistics for a benchmark run.
SimpleBench
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