diff options
Diffstat (limited to 'crates/ra_prof/src/lib.rs')
-rw-r--r-- | crates/ra_prof/src/lib.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 9ecb8e744..e56446c9f 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -1,13 +1,14 @@ | |||
1 | use std::cell::RefCell; | 1 | use std::{ |
2 | use std::time::{Duration, Instant}; | 2 | cell::RefCell, |
3 | use std::mem; | 3 | time::{Duration, Instant}, |
4 | use std::io::{stderr, Write}; | 4 | mem, |
5 | use std::iter::repeat; | 5 | io::{stderr, Write}, |
6 | use std::collections::{HashSet}; | 6 | iter::repeat, |
7 | use std::default::Default; | 7 | collections::HashSet, |
8 | use std::iter::FromIterator; | 8 | sync::{RwLock, atomic::{AtomicBool, Ordering}}, |
9 | use std::sync::{RwLock, atomic::{AtomicBool, Ordering}}; | 9 | }; |
10 | use lazy_static::lazy_static; | 10 | |
11 | use once_cell::sync::Lazy; | ||
11 | 12 | ||
12 | /// Set profiling filter. It specifies descriptions allowed to profile. | 13 | /// Set profiling filter. It specifies descriptions allowed to profile. |
13 | /// This is helpful when call stack has too many nested profiling scopes. | 14 | /// This is helpful when call stack has too many nested profiling scopes. |
@@ -21,7 +22,7 @@ use lazy_static::lazy_static; | |||
21 | /// ``` | 22 | /// ``` |
22 | pub fn set_filter(f: Filter) { | 23 | pub fn set_filter(f: Filter) { |
23 | PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst); | 24 | PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst); |
24 | let set = HashSet::from_iter(f.allowed.iter().cloned()); | 25 | let set: HashSet<_> = f.allowed.iter().cloned().collect(); |
25 | let mut old = FILTER.write().unwrap(); | 26 | let mut old = FILTER.write().unwrap(); |
26 | let filter_data = FilterData { | 27 | let filter_data = FilterData { |
27 | depth: f.depth, | 28 | depth: f.depth, |
@@ -161,9 +162,7 @@ struct FilterData { | |||
161 | 162 | ||
162 | static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false); | 163 | static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false); |
163 | 164 | ||
164 | lazy_static! { | 165 | static FILTER: Lazy<RwLock<FilterData>> = Lazy::new(Default::default); |
165 | static ref FILTER: RwLock<FilterData> = RwLock::new(Default::default()); | ||
166 | } | ||
167 | 166 | ||
168 | thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new())); | 167 | thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new())); |
169 | 168 | ||