wall_clock_timer.rs
This file
Path
src/timer/wall_clock_timer.rs
22 lines · 476 bytes · Rust
Last changed by
Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
History of this fileTake it
1use std::time::Instant;23use crate::quantity::{nanosecond, second, Time};45pub struct WallClockTimer {6 start: Instant,7}89impl WallClockTimer {10 pub fn start() -> WallClockTimer {11 WallClockTimer {12 start: Instant::now(),13 }14 }1516 pub fn stop(&self) -> Time {17 let duration = self.start.elapsed();1819 Time::new::<second>(duration.as_secs() as f64)20 + Time::new::<nanosecond>(duration.subsec_nanos() as f64)21 }22}