aboutsummaryrefslogtreecommitdiff
path: root/crates/profile/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-22 14:53:47 +0100
committerAleksey Kladov <[email protected]>2021-05-22 14:53:47 +0100
commit188b0f96f98feaa0771f941343887c46113c8ced (patch)
tree870d3afb3479ea9f0c323d7c539ce615ec4a4651 /crates/profile/src
parente6776c3e1b66c8946873d20e1e3bc1d743c952fe (diff)
Add more docs
Diffstat (limited to 'crates/profile/src')
-rw-r--r--crates/profile/src/lib.rs2
-rw-r--r--crates/profile/src/memory_usage.rs6
-rw-r--r--crates/profile/src/stop_watch.rs4
3 files changed, 7 insertions, 5 deletions
diff --git a/crates/profile/src/lib.rs b/crates/profile/src/lib.rs
index a31fb8f43..7cd01a7df 100644
--- a/crates/profile/src/lib.rs
+++ b/crates/profile/src/lib.rs
@@ -124,5 +124,5 @@ impl Drop for CpuSpan {
124} 124}
125 125
126pub fn memory_usage() -> MemoryUsage { 126pub fn memory_usage() -> MemoryUsage {
127 MemoryUsage::current() 127 MemoryUsage::now()
128} 128}
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs
index cb4e54447..2917ded60 100644
--- a/crates/profile/src/memory_usage.rs
+++ b/crates/profile/src/memory_usage.rs
@@ -1,4 +1,6 @@
1//! FIXME: write short doc here 1//! Like [`std::time::Instant`], but for memory.
2//!
3//! Measures the total size of all currently allocated objects.
2use std::fmt; 4use std::fmt;
3 5
4use cfg_if::cfg_if; 6use cfg_if::cfg_if;
@@ -22,7 +24,7 @@ impl std::ops::Sub for MemoryUsage {
22} 24}
23 25
24impl MemoryUsage { 26impl MemoryUsage {
25 pub fn current() -> MemoryUsage { 27 pub fn now() -> MemoryUsage {
26 cfg_if! { 28 cfg_if! {
27 if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { 29 if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
28 jemalloc_ctl::epoch::advance().unwrap(); 30 jemalloc_ctl::epoch::advance().unwrap();
diff --git a/crates/profile/src/stop_watch.rs b/crates/profile/src/stop_watch.rs
index cb6915d45..112d03a9c 100644
--- a/crates/profile/src/stop_watch.rs
+++ b/crates/profile/src/stop_watch.rs
@@ -44,7 +44,7 @@ impl StopWatch {
44 } 44 }
45 pub fn memory(mut self, yes: bool) -> StopWatch { 45 pub fn memory(mut self, yes: bool) -> StopWatch {
46 if yes { 46 if yes {
47 self.memory = Some(MemoryUsage::current()); 47 self.memory = Some(MemoryUsage::now());
48 } 48 }
49 self 49 self
50 } 50 }
@@ -58,7 +58,7 @@ impl StopWatch {
58 #[cfg(not(target_os = "linux"))] 58 #[cfg(not(target_os = "linux"))]
59 let instructions = None; 59 let instructions = None;
60 60
61 let memory = self.memory.map(|it| MemoryUsage::current() - it); 61 let memory = self.memory.map(|it| MemoryUsage::now() - it);
62 StopWatchSpan { time, instructions, memory } 62 StopWatchSpan { time, instructions, memory }
63 } 63 }
64} 64}