Skip to content
Myr

wall_clock_timer.rs

This file

Path

src/timer/wall_clock_timer.rs

20 lines · 413 bytes · Rust

Last changed by

Move to timer moduleDavid Peterbefore adoption0ffc6d7

History of this file

Take it

1use std::time::Instant;23use crate::util::units::Second;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) -> Second {17        let duration = self.start.elapsed();18        duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-919    }20}