Function tiny_bench::bench_with_configuration

source ยท
pub fn bench_with_configuration<T, F: FnMut() -> T>(
    cfg: &BenchmarkConfig,
    closure: F,
)
Expand description

Will run the benchmark with the supplied configuration

use std::time::Duration;
use tiny_bench::{bench_with_configuration, BenchmarkConfig};
bench_with_configuration(&BenchmarkConfig {
    measurement_time: Duration::from_secs(10),
    ..BenchmarkConfig::default()
}, || {
    // Some code that should be benched
})
Examples found in repository?
examples/bad_sort.rs (lines 5-8)
3
4
5
6
7
8
9
fn main() {
    let v = vec![10, 5, 3, 8, 7, 5];
    tiny_bench::bench_with_configuration(&BenchmarkConfig::default(), || {
        let sorted = bad_sort(v.clone());
        assert_eq!(vec![3, 5, 5, 7, 8, 10], sorted);
    });
}