From 98cc51580d0b8a6662f0155d8a45a8cfff469d72 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 16 Feb 2020 18:04:08 +0100 Subject: Enable profiling for bench --- crates/ra_cli/src/analysis_bench.rs | 2 ++ crates/ra_lsp_server/src/main.rs | 7 +------ crates/ra_prof/src/lib.rs | 7 +++++++ 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 5485a38ff..764df6b9e 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs @@ -20,6 +20,8 @@ pub(crate) enum Op { } pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { + ra_prof::init(); + let start = Instant::now(); eprint!("loading: "); let (mut host, roots) = ra_batch::load_cargo(path)?; diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index c8a017c5c..ed2eaabd4 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -15,13 +15,8 @@ fn main() -> Result<()> { fn setup_logging() -> Result<()> { std::env::set_var("RUST_BACKTRACE", "short"); - env_logger::try_init()?; - - ra_prof::set_filter(match std::env::var("RA_PROFILE") { - Ok(spec) => ra_prof::Filter::from_spec(&spec), - Err(_) => ra_prof::Filter::disabled(), - }); + ra_prof::init(); Ok(()) } diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index d38ff397e..c0bfbc2ee 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -26,6 +26,13 @@ pub use crate::memory_usage::{Bytes, MemoryUsage}; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; +pub fn init() { + set_filter(match std::env::var("RA_PROFILE") { + Ok(spec) => Filter::from_spec(&spec), + Err(_) => Filter::disabled(), + }); +} + /// Set profiling filter. It specifies descriptions allowed to profile. /// This is helpful when call stack has too many nested profiling scopes. /// Additionally filter can specify maximum depth of profiling scopes nesting. -- cgit v1.2.3