Documentation
use std::time::Instant;

pub struct Stopwatch(pub Instant);
impl Stopwatch {
    pub fn now() -> Self {
        Self(Instant::now())
    }
    pub fn print_reset(&mut self, msg: impl ToString) {
        tracing::info!(
            target: "dutils",
            "{}: {:.2} ms",
            msg.to_string(),
            self.0.elapsed().as_secs_f32() * 1000.0
        );
        self.0 = Instant::now();
    }

    pub fn reset_ms(&mut self) -> f32 {
        let v = self.0.elapsed().as_secs_f32() * 1000.0;
        self.0 = Instant::now();
        v
    }

    pub fn reset_s(&mut self) -> f32 {
        let v = self.0.elapsed().as_secs_f32();
        self.0 = Instant::now();
        v
    }
}