[][src]Function testbench::benchmark

pub fn benchmark(num_iterations: u32, iteration: impl FnMut())

Microbenchmark some simple operation by running it N times

This simple benchmark harness is meant as a cheap and hackish substitute for cargo benchmarks in Stable Rust. It runs a user-provided operation a certain number of times and measures how much time it takes.

To use it, write your benchmark as an ignored cargo test, put a call to benchmark() as the last operation, and tell your user to run the benchmarks via:

$ cargo test --release -- --ignored --nocapture --test-threads=1

This is a dreadful hack. But for now, it's the best that I've thought of.