Files
hyperfine/src/hyperfine/timer/wallclocktimer.rs
T

23 lines
470 B
Rust
Raw Normal View History

2018-02-02 17:28:52 +01:00
use std::time::Instant;
use hyperfine::internal::Second;
use hyperfine::timer::Timer;
pub struct WallClockTimer {
start: Instant,
}
impl Timer for WallClockTimer {
type Result = Second;
fn start() -> WallClockTimer {
WallClockTimer {
start: Instant::now(),
}
}
fn stop(&self) -> Second {
let duration = self.start.elapsed();
duration.as_secs() as f64 + (duration.subsec_nanos() as f64) * 1e-9
}
}