mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
fix test
This commit is contained in:
parent
c4a5aa45dc
commit
247ac265f1
1 changed files with 6 additions and 17 deletions
|
@ -15,14 +15,10 @@ use lazy_static::lazy_static;
|
||||||
///
|
///
|
||||||
/// #Example
|
/// #Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use ra_prof::set_filter;
|
/// use ra_prof::{set_filter, Filter};
|
||||||
/// use ra_prof::Filter;
|
/// let f = Filter::from_spec("profile1|profile2@2");
|
||||||
/// let max_depth = 2;
|
|
||||||
/// let allowed = vec!["profile1".to_string(), "profile2".to_string()];
|
|
||||||
/// let f = Filter::new( max_depth, allowed );
|
|
||||||
/// set_filter(f);
|
/// set_filter(f);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
pub fn set_filter(f: Filter) {
|
pub fn set_filter(f: Filter) {
|
||||||
PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
|
PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
|
||||||
let set = HashSet::from_iter(f.allowed.iter().cloned());
|
let set = HashSet::from_iter(f.allowed.iter().cloned());
|
||||||
|
@ -43,12 +39,9 @@ pub fn set_filter(f: Filter) {
|
||||||
///
|
///
|
||||||
/// #Example
|
/// #Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use ra_prof::profile;
|
/// use ra_prof::{profile, set_filter, Filter};
|
||||||
/// use ra_prof::set_filter;
|
|
||||||
/// use ra_prof::Filter;
|
|
||||||
///
|
///
|
||||||
/// let allowed = vec!["profile1".to_string(), "profile2".to_string()];
|
/// let f = Filter::from_spec("profile1|profile2@2");
|
||||||
/// let f = Filter::new(2, allowed);
|
|
||||||
/// set_filter(f);
|
/// set_filter(f);
|
||||||
/// profiling_function1();
|
/// profiling_function1();
|
||||||
///
|
///
|
||||||
|
@ -66,7 +59,6 @@ pub fn set_filter(f: Filter) {
|
||||||
/// 0ms - profile
|
/// 0ms - profile
|
||||||
/// 0ms - profile2
|
/// 0ms - profile2
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
pub fn profile(desc: &str) -> Profiler {
|
pub fn profile(desc: &str) -> Profiler {
|
||||||
assert!(!desc.is_empty());
|
assert!(!desc.is_empty());
|
||||||
if !PROFILING_ENABLED.load(Ordering::Relaxed) {
|
if !PROFILING_ENABLED.load(Ordering::Relaxed) {
|
||||||
|
@ -220,15 +212,12 @@ fn print(lvl: usize, msgs: &[Message], out: &mut impl Write) {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
use super::profile;
|
|
||||||
use super::set_filter;
|
|
||||||
use super::Filter;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_basic_profile() {
|
fn test_basic_profile() {
|
||||||
let s = vec!["profile1".to_string(), "profile2".to_string()];
|
let s = vec!["profile1".to_string(), "profile2".to_string()];
|
||||||
let f = Filter::new(2, s);
|
let f = Filter::new(2, s, Duration::new(0, 0));
|
||||||
set_filter(f);
|
set_filter(f);
|
||||||
profiling_function1();
|
profiling_function1();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue