aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_prof/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-30 11:42:23 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-30 11:42:23 +0100
commit2ad8220f58675193860337a00fed87162a98dc1a (patch)
treee39c335b575481fb40b183c82db25a222076c96b /crates/ra_prof/src/lib.rs
parentbb70d18a0a51a2321780e8eaa0262ec61a659b05 (diff)
parent18a1e092e9406c6670cd38d17997325bba7bbfdc (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.rs14
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 @@
1mod memory_usage;
2
1use std::{ 3use std::{
2 cell::RefCell, 4 cell::RefCell,
3 time::{Duration, Instant}, 5 time::{Duration, Instant},
@@ -11,6 +13,14 @@ use std::{
11use once_cell::sync::Lazy; 13use once_cell::sync::Lazy;
12use itertools::Itertools; 14use itertools::Itertools;
13 15
16pub 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]
22static 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
301pub fn memory_usage() -> MemoryUsage {
302 MemoryUsage::current()
303}
304
291#[cfg(test)] 305#[cfg(test)]
292mod tests { 306mod tests {
293 use super::*; 307 use super::*;