aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_prof/Cargo.toml5
-rw-r--r--crates/ra_prof/src/lib.rs2
-rw-r--r--crates/stdx/src/lib.rs2
3 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml
index c33b5121a..eabfcebb0 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 }
20[features] 20[features]
21jemalloc = [ "jemallocator", "jemalloc-ctl" ] 21jemalloc = [ "jemallocator", "jemalloc-ctl" ]
22cpu_profiler = [] 22cpu_profiler = []
23
24# Uncomment to enable for the whole crate graph
25# default = [ "backtrace" ]
26# default = [ "jemalloc" ]
27# default = [ "cpu_profiler" ]
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index 89df7f04b..0fb468375 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -43,6 +43,7 @@ pub struct Scope {
43} 43}
44 44
45impl Scope { 45impl Scope {
46 #[must_use]
46 pub fn enter() -> Scope { 47 pub fn enter() -> Scope {
47 let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true)); 48 let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true));
48 Scope { prev } 49 Scope { prev }
@@ -78,6 +79,7 @@ pub struct CpuProfiler {
78 _private: (), 79 _private: (),
79} 80}
80 81
82#[must_use]
81pub fn cpu_profiler() -> CpuProfiler { 83pub fn cpu_profiler() -> CpuProfiler {
82 #[cfg(feature = "cpu_profiler")] 84 #[cfg(feature = "cpu_profiler")]
83 { 85 {
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index 08ac6f70f..3b605c79d 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -87,6 +87,8 @@ where
87 Ok(()) 87 Ok(())
88 } 88 }
89} 89}
90
91#[must_use]
90pub fn timeit(label: &'static str) -> impl Drop { 92pub fn timeit(label: &'static str) -> impl Drop {
91 struct Guard { 93 struct Guard {
92 label: &'static str, 94 label: &'static str,