Capture memory usage metrics

This commit is contained in:
Jonas Schievink 2020-12-11 17:30:32 +01:00
parent e68110c082
commit 7fc4ba000e

View file

@ -3,6 +3,7 @@ use std::{
env, env,
io::Write as _, io::Write as _,
path::Path, path::Path,
process::{Command, Stdio},
time::{Instant, SystemTime, UNIX_EPOCH}, time::{Instant, SystemTime, UNIX_EPOCH},
}; };
@ -81,7 +82,11 @@ impl Metrics {
} }
fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> { fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
eprintln!("\nMeasuring analysis-stats/{}", name); eprintln!("\nMeasuring analysis-stats/{}", name);
let output = cmd!("./target/release/rust-analyzer analysis-stats --quiet {path}").read()?; let output = Command::new("./target/release/rust-analyzer")
.args(&["analysis-stats", "--quiet", "--memory-usage", path])
.stdout(Stdio::inherit())
.output()?;
let output = String::from_utf8(output.stdout)?;
for (metric, value, unit) in parse_metrics(&output) { for (metric, value, unit) in parse_metrics(&output) {
self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into()); self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());
} }