Crates.io | benchmark-simple |
lib.rs | benchmark-simple |
version | 0.1.10 |
source | src |
created_at | 2021-10-19 19:00:17.051222 |
updated_at | 2024-11-05 11:28:37.543356 |
description | A tiny, super simple and portable benchmarking library. |
homepage | https://github.com/jedisct1/rust-benchmark-simple |
repository | https://github.com/jedisct1/rust-benchmark-simple |
max_upload_size | |
id | 467472 |
size | 14,260 |
A tiny benchmarking library for Rust.
use benchmark_simple::*;
fn test_function() {
// ...
}
let bench = Bench::new();
let options = Options::default();
let res = bench.run(&options, || test_function());
println!("result: {}", res);
Throughput computation:
use benchmark_simple::*;
fn test_function(m: &mut [u8]) {
// ...
}
let mut m = vec![0u8; 1_000_000];
let bench = Bench::new();
let options = Options::default();
let res = bench.run(&options, || test_function(&mut m));
let throughput = res.throughput(m.len() as _);
println!("throughput: {}", throughput);
Options:
pub struct Options {
/// Number of iterations to perform.
pub iterations: u64,
/// Number of warm-up iterations to perform.
pub warmup_iterations: u64,
/// Minimum number of samples to collect.
pub min_samples: usize,
/// Maximum number of samples to collect.
pub max_samples: usize,
/// Maximum RSD to tolerate (in 0...100).
pub max_rsd: f64,
/// Maximum benchmark duration time.
pub max_duration: Option<std::time::Duration>,
/// Verbose output
pub verbose: bool,
}
Benchmark results can be made verbose by setting verbose
to true
in the
Options
struct, or by defining a BENCHMARK_VERBOSE
environment variable.