From e7ba7f47a79a2881cf208ef9d944609e8fd4eec9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Jul 2020 03:04:37 +0200 Subject: [PATCH] Profiling tweaks --- crates/ra_prof/Cargo.toml | 5 +++++ crates/ra_prof/src/lib.rs | 2 ++ crates/stdx/src/lib.rs | 2 ++ 3 files changed, 9 insertions(+) diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index c33b5121ae2..eabfcebb071 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml @@ -20,3 +20,8 @@ jemalloc-ctl = { version = "0.3.3", optional = true } [features] jemalloc = [ "jemallocator", "jemalloc-ctl" ] cpu_profiler = [] + +# Uncomment to enable for the whole crate graph +# default = [ "backtrace" ] +# default = [ "jemalloc" ] +# default = [ "cpu_profiler" ] diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 89df7f04b7f..0fb46837552 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -43,6 +43,7 @@ pub struct Scope { } impl Scope { + #[must_use] pub fn enter() -> Scope { let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true)); Scope { prev } @@ -78,6 +79,7 @@ pub struct CpuProfiler { _private: (), } +#[must_use] pub fn cpu_profiler() -> CpuProfiler { #[cfg(feature = "cpu_profiler")] { diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 08ac6f70f39..3b605c79dd6 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -87,6 +87,8 @@ where Ok(()) } } + +#[must_use] pub fn timeit(label: &'static str) -> impl Drop { struct Guard { label: &'static str,