aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_cli/src')
-rw-r--r--crates/ra_cli/src/analysis_stats.rs11
-rw-r--r--crates/ra_cli/src/main.rs4
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
7use crate::Result; 7use crate::Result;
8 8
9pub fn run(verbose: bool, path: &Path, only: Option<&str>) -> Result<()> { 9pub 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");