From b33b843f408fe73bde920c087de0622f46e853e5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Mar 2020 17:23:08 +0100 Subject: Allow specifying additional info on call to profile --- crates/ra_prof/src/lib.rs | 57 +++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'crates/ra_prof/src') diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 6853a4794..9e167db96 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -88,7 +88,7 @@ pub type Label = &'static str; pub fn profile(label: Label) -> Profiler { assert!(!label.is_empty()); if !PROFILING_ENABLED.load(Ordering::Relaxed) { - return Profiler { label: None }; + return Profiler { label: None, detail: None }; } PROFILE_STACK.with(|stack| { @@ -101,15 +101,15 @@ pub fn profile(label: Label) -> Profiler { }; } if stack.starts.len() > stack.filter_data.depth { - return Profiler { label: None }; + return Profiler { label: None, detail: None }; } let allowed = &stack.filter_data.allowed; if stack.starts.is_empty() && !allowed.is_empty() && !allowed.contains(label) { - return Profiler { label: None }; + return Profiler { label: None, detail: None }; } stack.starts.push(Instant::now()); - Profiler { label: Some(label) } + Profiler { label: Some(label), detail: None } }) } @@ -130,6 +130,16 @@ pub fn print_time(label: Label) -> impl Drop { pub struct Profiler { label: Option