1 2 3 4 5 6 7 8 9
use std::time::{Duration, Instant}; /// Invokes `f` once and returns its latency. #[inline(always)] pub fn latency(f: impl FnOnce()) -> Duration { let start = Instant::now(); f(); Instant::now().duration_since(start) }