wallclocktimer.rs
This file
Path
src/timer/wallclocktimer.rs
20 lines · 413 bytes · Rust
Last changed by
Refactor timer moduleDavid Peterbefore adoptiondefafdf
History of this fileTake it
Flat directory/module structureDavid Peterbefore adoption30c381f
lines 1–2why, one step back1use std::time::Instant;2Move a few modules to utilDavid Peterbefore adoption5c634c9
line 3why, one step back3use crate::util::units::Second;Flat directory/module structureDavid Peterbefore adoption30c381f
lines 4–8why, one step back45pub struct WallClockTimer {6 start: Instant,7}8Refactor timer moduleDavid Peterbefore adoptiondefafdf
lines 9–10why, one step back9impl WallClockTimer {10 pub fn start() -> WallClockTimer {Flat directory/module structureDavid Peterbefore adoption30c381f
lines 11–15why, one step back11 WallClockTimer {12 start: Instant::now(),13 }14 }15Refactor timer moduleDavid Peterbefore adoptiondefafdf
line 16why, one step back16 pub fn stop(&self) -> Second {Flat directory/module structureDavid Peterbefore adoption30c381f
lines 17–20why, one step back17 let duration = self.start.elapsed();18 duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-919 }20}