Skip to main content

Crate dev_bench

Crate dev_bench 

Source
Expand description

§dev-bench

Performance measurement and regression detection for Rust. Part of the dev-* verification suite.

dev-bench answers the question: did this change make the code faster, slower, or stay the same? It compares current measurements against a stored baseline and emits verdicts via dev-report.

§Quick example

use dev_bench::{Benchmark, Threshold};

let mut b = Benchmark::new("parse_query");
for _ in 0..1000 {
    b.iter(|| {
        std::hint::black_box(40 + 2);
    });
}

let result = b.finish();
let threshold = Threshold::regression_pct(10.0);   // fail on +10%
let _check = result.compare_against_baseline(None, threshold);

§What’s measured

Per-sample wall-clock duration captured via Instant::now(). From the samples, dev-bench reports mean, p50, p99, cv, and a derived ops_per_sec throughput. See BenchmarkResult.

§Features

  • alloc-tracking (opt-in): measures allocation count and bytes alongside time, using dhat. See the alloc module.

Re-exports§

pub use baseline::Baseline;
pub use baseline::BaselineStore;
pub use baseline::JsonFileBaselineStore;

Modules§

allocalloc-tracking
Allocation tracking. Available with the alloc-tracking feature.
baseline
Baseline storage for benchmark results.

Structs§

BenchProducer
Producer wrapper that runs a benchmark and emits a single-check Report via Producer::produce.
Benchmark
A single benchmark run.
BenchmarkResult
The result of a finished benchmark.
CompareOptions
Options for BenchmarkResult::compare_with_options.

Enums§

Threshold
A threshold defining how much slower-than-baseline is acceptable.

Traits§

Bench
A trait for any object that can run a benchmark and produce a result.