Skip to content
Myr

wall_clock_timer.rs

This file

Path

src/timer/wall_clock_timer.rs

22 lines · 468 bytes · Rust

Last changed by

Move quantity moduleDavid Peterbefore adoptionbe66a66

History of this file

Take it

1use std::time::Instant;23use crate::quantity::{Time, TimeQuantity};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::from_seconds(duration.as_secs() as f64)20            + Time::from_nanoseconds(duration.subsec_nanos() as f64)21    }22}