aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_prof/src/lib.rs
diff options
context:
space:
mode:
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::*;