Files
hyperfine/src/timer/wall_clock_timer.rs
T
2022-02-22 13:24:05 +01:00

21 lines
413 B
Rust

use std::time::Instant;
use crate::util::units::Second;
pub struct WallClockTimer {
start: Instant,
}
impl WallClockTimer {
pub fn start() -> WallClockTimer {
WallClockTimer {
start: Instant::now(),
}
}
pub fn stop(&self) -> Second {
let duration = self.start.elapsed();
duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-9
}
}