1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::stream_engine::time::{
duration::{wall_clock_duration::WallClockDuration, SpringDuration},
timestamp::{SpringTimestamp, SystemTimestamp},
};
#[derive(Debug)]
pub struct WallClockStopwatch {
start_at: SpringTimestamp,
}
impl WallClockStopwatch {
pub fn start() -> Self {
let start_at = SystemTimestamp::now();
Self { start_at }
}
pub fn stop(&self) -> WallClockDuration {
let stop_at = SystemTimestamp::now();
assert!(stop_at >= self.start_at);
let duration = stop_at - self.start_at;
WallClockDuration::from_std(duration.to_std().expect("chrono to_std"))
}
}