hydro2_network_performance/
stats.rs1crate::ix!();
3
4#[derive(Setters,Getters,Debug)]
6#[getset(get="pub",set="pub")]
7pub struct PerformanceStats {
8
9 start_time: Instant,
11
12 end_time: Option<Instant>,
14
15 operators_executed: usize,
17
18 peak_memory_bytes: usize,
20}
21
22impl PerformanceStats {
23 pub fn start() -> Self {
25 Self {
26 start_time: Instant::now(),
27 end_time: None,
28 operators_executed: 0,
29 peak_memory_bytes: 0,
30 }
31 }
32
33 pub fn end(&mut self) {
35 self.end_time = Some(Instant::now());
36 }
37
38 pub fn total_duration(&self) -> Option<Duration> {
40 match self.end_time {
41 Some(t) => Some(t.duration_since(self.start_time)),
42 None => None,
43 }
44 }
45}
46