Move to timer module

This commit is contained in:
David Peter authored and David Peter committed 2022-02-22 13:24:05 +01:00
1 parent 1f3943e7d1
commit 0ffc6d7cc0
6 files changed
+61 -62

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
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
}
}