diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-30 12:50:11 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-30 12:50:11 +0100 |
commit | 79298b97228f09e0c5c51799700d8350f5468ed5 (patch) | |
tree | 74cde977e61652f9bd0af6c62449037ac100e94f /crates/ra_cli/src | |
parent | 2ad8220f58675193860337a00fed87162a98dc1a (diff) | |
parent | d70520eb38c3f39823186c3b352efe4c910417f1 (diff) |
Merge #1463
1463: print memory usage for queries r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_cli/src')
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 11 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index 2eaf784a6..a01c07c3f 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -6,9 +6,9 @@ use ra_syntax::AstNode; | |||
6 | 6 | ||
7 | use crate::Result; | 7 | use crate::Result; |
8 | 8 | ||
9 | pub fn run(verbose: bool, path: &Path, only: Option<&str>) -> Result<()> { | 9 | pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -> Result<()> { |
10 | let db_load_time = Instant::now(); | 10 | let db_load_time = Instant::now(); |
11 | let (host, roots) = ra_batch::load_cargo(path)?; | 11 | let (mut host, roots) = ra_batch::load_cargo(path)?; |
12 | let db = host.raw_database(); | 12 | let db = host.raw_database(); |
13 | println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); | 13 | println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); |
14 | let analysis_time = Instant::now(); | 14 | let analysis_time = Instant::now(); |
@@ -113,5 +113,12 @@ pub fn run(verbose: bool, path: &Path, only: Option<&str>) -> Result<()> { | |||
113 | (num_exprs_partially_unknown * 100 / num_exprs) | 113 | (num_exprs_partially_unknown * 100 / num_exprs) |
114 | ); | 114 | ); |
115 | println!("Analysis: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); | 115 | println!("Analysis: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); |
116 | |||
117 | if memory_usage { | ||
118 | for (name, bytes) in host.per_query_memory_usage() { | ||
119 | println!("{:>8} {}", bytes, name) | ||
120 | } | ||
121 | } | ||
122 | |||
116 | Ok(()) | 123 | Ok(()) |
117 | } | 124 | } |
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 5adf8b096..d2f6544f8 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -24,6 +24,7 @@ fn main() -> Result<()> { | |||
24 | .subcommand( | 24 | .subcommand( |
25 | SubCommand::with_name("analysis-stats") | 25 | SubCommand::with_name("analysis-stats") |
26 | .arg(Arg::with_name("verbose").short("v").long("verbose")) | 26 | .arg(Arg::with_name("verbose").short("v").long("verbose")) |
27 | .arg(Arg::with_name("memory-usage").long("memory-usage")) | ||
27 | .arg(Arg::with_name("only").short("o").takes_value(true)) | 28 | .arg(Arg::with_name("only").short("o").takes_value(true)) |
28 | .arg(Arg::with_name("path")), | 29 | .arg(Arg::with_name("path")), |
29 | ) | 30 | ) |
@@ -71,9 +72,10 @@ fn main() -> Result<()> { | |||
71 | } | 72 | } |
72 | ("analysis-stats", Some(matches)) => { | 73 | ("analysis-stats", Some(matches)) => { |
73 | let verbose = matches.is_present("verbose"); | 74 | let verbose = matches.is_present("verbose"); |
75 | let memory_usage = matches.is_present("memory-usage"); | ||
74 | let path = matches.value_of("path").unwrap_or(""); | 76 | let path = matches.value_of("path").unwrap_or(""); |
75 | let only = matches.value_of("only"); | 77 | let only = matches.value_of("only"); |
76 | analysis_stats::run(verbose, path.as_ref(), only)?; | 78 | analysis_stats::run(verbose, memory_usage, path.as_ref(), only)?; |
77 | } | 79 | } |
78 | ("analysis-bench", Some(matches)) => { | 80 | ("analysis-bench", Some(matches)) => { |
79 | let verbose = matches.is_present("verbose"); | 81 | let verbose = matches.is_present("verbose"); |