diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-03 10:09:11 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-03 10:09:11 +0100 |
commit | c6c88070c4f25cd3710f03b7461cb277de8d3cc5 (patch) | |
tree | cfe6ec2fb43dcfb9a7f1c5698aaac0d17b2bf78a /crates/ra_lsp_server/src/main.rs | |
parent | b8e58d4a2f317fe300f13416858f33e860138c4d (diff) | |
parent | b74449e9952846a8ea66c3507e52c24348d6dbc9 (diff) |
Merge #1068
1068: profiling crate first draft r=matklad a=pasa
I've made this first draft for #961
Could you look at it? Is this something what you are looking for?
It has lack of tests. I can't figure out how to test stderr output in rust right now. Do you have some clues?
Additionally I'm thinking about to implement procedural macros to annotate methods with this profiler. Will it be helpful?
Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 5a2905207..eb4091a3d 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -3,6 +3,7 @@ use flexi_logger::{Duplicate, Logger}; | |||
3 | use gen_lsp_server::{run_server, stdio_transport}; | 3 | use gen_lsp_server::{run_server, stdio_transport}; |
4 | 4 | ||
5 | use ra_lsp_server::{Result, InitializationOptions}; | 5 | use ra_lsp_server::{Result, InitializationOptions}; |
6 | use ra_prof; | ||
6 | 7 | ||
7 | fn main() -> Result<()> { | 8 | fn main() -> Result<()> { |
8 | ::std::env::set_var("RUST_BACKTRACE", "short"); | 9 | ::std::env::set_var("RUST_BACKTRACE", "short"); |
@@ -11,6 +12,15 @@ fn main() -> Result<()> { | |||
11 | Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, | 12 | Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, |
12 | _ => logger.start()?, | 13 | _ => logger.start()?, |
13 | }; | 14 | }; |
15 | let prof_depth = match ::std::env::var("RA_PROFILE_DEPTH") { | ||
16 | Ok(ref d) => d.parse()?, | ||
17 | _ => 0, | ||
18 | }; | ||
19 | let profile_allowed = match ::std::env::var("RA_PROFILE") { | ||
20 | Ok(ref p) => p.split(";").map(String::from).collect(), | ||
21 | _ => Vec::new(), | ||
22 | }; | ||
23 | ra_prof::set_filter(ra_prof::Filter::new(prof_depth, profile_allowed)); | ||
14 | log::info!("lifecycle: server started"); | 24 | log::info!("lifecycle: server started"); |
15 | match ::std::panic::catch_unwind(main_inner) { | 25 | match ::std::panic::catch_unwind(main_inner) { |
16 | Ok(res) => { | 26 | Ok(res) => { |