Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/profile/src/stop_watch.rs')
-rw-r--r--crates/profile/src/stop_watch.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/crates/profile/src/stop_watch.rs b/crates/profile/src/stop_watch.rs
index 71303d5a63..814a025740 100644
--- a/crates/profile/src/stop_watch.rs
+++ b/crates/profile/src/stop_watch.rs
@@ -10,13 +10,13 @@ pub struct StopWatch {
time: Instant,
#[cfg(target_os = "linux")]
counter: Option<perf_event::Counter>,
- memory: Option<MemoryUsage>,
+ memory: MemoryUsage,
}
pub struct StopWatchSpan {
pub time: Duration,
pub instructions: Option<u64>,
- pub memory: Option<MemoryUsage>,
+ pub memory: MemoryUsage,
}
impl StopWatch {
@@ -45,20 +45,16 @@ impl StopWatch {
None
}
};
+ let memory = MemoryUsage::now();
let time = Instant::now();
StopWatch {
time,
#[cfg(target_os = "linux")]
counter,
- memory: None,
+ memory,
}
}
- pub fn memory(mut self, yes: bool) -> StopWatch {
- if yes {
- self.memory = Some(MemoryUsage::now());
- }
- self
- }
+
pub fn elapsed(&mut self) -> StopWatchSpan {
let time = self.time.elapsed();
@@ -69,7 +65,7 @@ impl StopWatch {
#[cfg(not(target_os = "linux"))]
let instructions = None;
- let memory = self.memory.map(|it| MemoryUsage::now() - it);
+ let memory = MemoryUsage::now() - self.memory;
StopWatchSpan { time, instructions, memory }
}
}
@@ -93,9 +89,7 @@ impl fmt::Display for StopWatchSpan {
}
write!(f, ", {instructions}{prefix}instr")?;
}
- if let Some(memory) = self.memory {
- write!(f, ", {memory}")?;
- }
+ write!(f, ", {}", self.memory)?;
Ok(())
}
}