From 188b0f96f98feaa0771f941343887c46113c8ced Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 May 2021 16:53:47 +0300 Subject: Add more docs --- crates/profile/src/lib.rs | 2 +- crates/profile/src/memory_usage.rs | 6 ++++-- crates/profile/src/stop_watch.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/profile/src') 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 { } pub fn memory_usage() -> MemoryUsage { - MemoryUsage::current() + MemoryUsage::now() } 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 @@ -//! FIXME: write short doc here +//! Like [`std::time::Instant`], but for memory. +//! +//! Measures the total size of all currently allocated objects. use std::fmt; use cfg_if::cfg_if; @@ -22,7 +24,7 @@ impl std::ops::Sub for MemoryUsage { } impl MemoryUsage { - pub fn current() -> MemoryUsage { + pub fn now() -> MemoryUsage { cfg_if! { if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { 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 { } pub fn memory(mut self, yes: bool) -> StopWatch { if yes { - self.memory = Some(MemoryUsage::current()); + self.memory = Some(MemoryUsage::now()); } self } @@ -58,7 +58,7 @@ impl StopWatch { #[cfg(not(target_os = "linux"))] let instructions = None; - let memory = self.memory.map(|it| MemoryUsage::current() - it); + let memory = self.memory.map(|it| MemoryUsage::now() - it); StopWatchSpan { time, instructions, memory } } } -- cgit v1.2.3