Skip to content
Myr

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 file

Take it

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 1–2why, one step back
1use std::time::Instant;
2

Move a few modules to utilDavid Peterbefore adoption5c634c9

line 3why, one step back
3use crate::util::units::Second;

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 4–8why, one step back
4
5pub struct WallClockTimer {6 start: Instant,7}8

Refactor timer moduleDavid Peterbefore adoptiondefafdf

lines 9–10why, one step back
9impl WallClockTimer {
10 pub fn start() -> WallClockTimer {

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 11–15why, one step back
11 WallClockTimer {
12 start: Instant::now(),13 }14 }15

Refactor timer moduleDavid Peterbefore adoptiondefafdf

line 16why, one step back
16 pub fn stop(&self) -> Second {

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 17–20why, one step back
17 let duration = self.start.elapsed();
18 duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-919 }20}