Function tiny_bench::run_timed

source ยท
pub fn run_timed<T, F: FnMut() -> T>(closure: F) -> Duration
Expand description

The simplest possible timed function that just runs some FnMut closure and returns the time it took

use std::time::Duration;
use tiny_bench::run_timed;
let time = run_timed(|| std::thread::sleep(Duration::from_micros(5)));
assert!(time.as_micros() >= 5);