remem/log/timer.rs
1pub struct Timer {
2 component: String,
3 start: std::time::Instant,
4}
5
6impl Timer {
7 pub fn start(component: &str, msg: &str) -> Self {
8 crate::log::info(component, &format!("START {}", msg));
9 Self {
10 component: component.to_string(),
11 start: std::time::Instant::now(),
12 }
13 }
14
15 pub fn done(self, msg: &str) {
16 let ms = self.start.elapsed().as_millis();
17 crate::log::info(&self.component, &format!("DONE {}ms {}", ms, msg));
18 }
19}