mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
print memory usage for queries
This commit is contained in:
parent
2ad8220f58
commit
d70520eb38
7 changed files with 101 additions and 13 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue