mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-12 15:37:49 +00:00
Move to timer module
This commit is contained in:
1 parent
1f3943e7d1
commit
0ffc6d7cc0
6 files changed
+61
-62
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user