diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-30 11:42:23 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-30 11:42:23 +0100 |
commit | 2ad8220f58675193860337a00fed87162a98dc1a (patch) | |
tree | e39c335b575481fb40b183c82db25a222076c96b /crates/ra_prof/src/lib.rs | |
parent | bb70d18a0a51a2321780e8eaa0262ec61a659b05 (diff) | |
parent | 18a1e092e9406c6670cd38d17997325bba7bbfdc (diff) |
Merge #1462
1462: Move memory usage statistics to ra_prof r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_prof/src/lib.rs')
-rw-r--r-- | crates/ra_prof/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 1e8d780ab..6f7918745 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | mod memory_usage; | ||
2 | |||
1 | use std::{ | 3 | use std::{ |
2 | cell::RefCell, | 4 | cell::RefCell, |
3 | time::{Duration, Instant}, | 5 | time::{Duration, Instant}, |
@@ -11,6 +13,14 @@ use std::{ | |||
11 | use once_cell::sync::Lazy; | 13 | use once_cell::sync::Lazy; |
12 | use itertools::Itertools; | 14 | use itertools::Itertools; |
13 | 15 | ||
16 | pub use crate::memory_usage::{MemoryUsage, Bytes}; | ||
17 | |||
18 | // We use jemalloc mainly to get heap usage statistics, actual performance | ||
19 | // difference is not measures. | ||
20 | #[cfg(feature = "jemalloc")] | ||
21 | #[global_allocator] | ||
22 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
23 | |||
14 | /// Set profiling filter. It specifies descriptions allowed to profile. | 24 | /// Set profiling filter. It specifies descriptions allowed to profile. |
15 | /// This is helpful when call stack has too many nested profiling scopes. | 25 | /// This is helpful when call stack has too many nested profiling scopes. |
16 | /// Additionally filter can specify maximum depth of profiling scopes nesting. | 26 | /// Additionally filter can specify maximum depth of profiling scopes nesting. |
@@ -288,6 +298,10 @@ impl Drop for CpuProfiler { | |||
288 | } | 298 | } |
289 | } | 299 | } |
290 | 300 | ||
301 | pub fn memory_usage() -> MemoryUsage { | ||
302 | MemoryUsage::current() | ||
303 | } | ||
304 | |||
291 | #[cfg(test)] | 305 | #[cfg(test)] |
292 | mod tests { | 306 | mod tests { |
293 | use super::*; | 307 | use super::*; |