wallclocktimer.rs
This file
Path
src/timer/wallclocktimer.rs
30 lines · 622 bytes · Rust
Last changed by
Flat directory/module structureDavid Peterbefore adoption30c381f
History of this fileTake it
Flat directory/module structureDavid Peterbefore adoption30c381f
lines 1–30why, one step back1use std::process::Child;2use std::time::Instant;34use crate::timer::{TimerStart, TimerStop};5use crate::units::Second;67pub struct WallClockTimer {8 start: Instant,9}1011impl TimerStart for WallClockTimer {12 fn start() -> WallClockTimer {13 WallClockTimer {14 start: Instant::now(),15 }16 }1718 fn start_for_process(_: &Child) -> Self {19 Self::start()20 }21}2223impl TimerStop for WallClockTimer {24 type Result = Second;2526 fn stop(&self) -> Second {27 let duration = self.start.elapsed();28 duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-929 }30}