Function devtimer::run_benchmark
source · pub fn run_benchmark(iters: usize, function: impl Fn(usize)) -> RunThroughReport
Expand description
The bench struct provides the benchmark
function that can be used
for benchmarking operations using the bench()
member function
Benchmark an operation by running multiple iterations.
This function returns a RunThroughReport
object which can be used to get
the benchmark results.
Example
use devtimer::run_benchmark;
fn main() {
// Run 10 iterations
let bench_result = run_benchmark(10, |_| {
// Fake a slow operation
std::thread::sleep(std::time::Duration::from_nanos(10000));
});
// Now print the benchmark results
bench_result.print_stats();
}