Skip to content
Myr

wallclocktimer.rs

This file

Path

src/timer/wallclocktimer.rs

30 lines · 628 bytes · Rust

Last changed by

Move a few modules to utilDavid Peterbefore adoption5c634c9

History of this file

Take it

1use std::process::Child;2use std::time::Instant;34use crate::timer::{TimerStart, TimerStop};5use crate::util::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}