about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-02-16 18:04:08 +0100
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-02-16 18:04:08 +0100
commit98cc51580d0b8a6662f0155d8a45a8cfff469d72 (patch)
treebf80d0d3a0d05f94732cddfb25eeb857b0cc8005
parentb98967d7658e2475d3b58d57950b8d1fb74156fa (diff)
downloadrust-98cc51580d0b8a6662f0155d8a45a8cfff469d72.tar.gz
rust-98cc51580d0b8a6662f0155d8a45a8cfff469d72.zip
Enable profiling for bench
-rw-r--r--crates/ra_cli/src/analysis_bench.rs2
-rw-r--r--crates/ra_lsp_server/src/main.rs7
-rw-r--r--crates/ra_prof/src/lib.rs7
3 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs
index 5485a38ff27..764df6b9efd 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 c8a017c5c80..ed2eaabd4ca 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 d38ff397e33..c0bfbc2ee14 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.