From d70520eb38c3f39823186c3b352efe4c910417f1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 30 Jun 2019 14:40:01 +0300 Subject: print memory usage for queries --- crates/ra_cli/src/analysis_stats.rs | 11 +++++++++-- crates/ra_cli/src/main.rs | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'crates/ra_cli/src') 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; use crate::Result; -pub fn run(verbose: bool, path: &Path, only: Option<&str>) -> Result<()> { +pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -> Result<()> { let db_load_time = Instant::now(); - let (host, roots) = ra_batch::load_cargo(path)?; + let (mut host, roots) = ra_batch::load_cargo(path)?; let db = host.raw_database(); println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); let analysis_time = Instant::now(); @@ -113,5 +113,12 @@ pub fn run(verbose: bool, path: &Path, only: Option<&str>) -> Result<()> { (num_exprs_partially_unknown * 100 / num_exprs) ); println!("Analysis: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); + + if memory_usage { + for (name, bytes) in host.per_query_memory_usage() { + println!("{:>8} {}", bytes, name) + } + } + Ok(()) } 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<()> { .subcommand( SubCommand::with_name("analysis-stats") .arg(Arg::with_name("verbose").short("v").long("verbose")) + .arg(Arg::with_name("memory-usage").long("memory-usage")) .arg(Arg::with_name("only").short("o").takes_value(true)) .arg(Arg::with_name("path")), ) @@ -71,9 +72,10 @@ fn main() -> Result<()> { } ("analysis-stats", Some(matches)) => { let verbose = matches.is_present("verbose"); + let memory_usage = matches.is_present("memory-usage"); let path = matches.value_of("path").unwrap_or(""); let only = matches.value_of("only"); - analysis_stats::run(verbose, path.as_ref(), only)?; + analysis_stats::run(verbose, memory_usage, path.as_ref(), only)?; } ("analysis-bench", Some(matches)) => { let verbose = matches.is_present("verbose"); -- cgit v1.2.3