mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Add self-analysis-stats to metrics
This commit is contained in:
parent
a09a00a560
commit
101cdc57c2
2 changed files with 43 additions and 22 deletions
|
@ -15,7 +15,7 @@ use xtask::{
|
||||||
codegen::{self, Mode},
|
codegen::{self, Mode},
|
||||||
dist::DistCmd,
|
dist::DistCmd,
|
||||||
install::{ClientOpt, InstallCmd, Malloc, ServerOpt},
|
install::{ClientOpt, InstallCmd, Malloc, ServerOpt},
|
||||||
metrics::run_metrics,
|
metrics::MetricsCmd,
|
||||||
not_bash::pushd,
|
not_bash::pushd,
|
||||||
pre_commit, project_root,
|
pre_commit, project_root,
|
||||||
release::{PromoteCmd, ReleaseCmd},
|
release::{PromoteCmd, ReleaseCmd},
|
||||||
|
@ -118,7 +118,11 @@ FLAGS:
|
||||||
args.finish()?;
|
args.finish()?;
|
||||||
DistCmd { nightly, client_version }.run()
|
DistCmd { nightly, client_version }.run()
|
||||||
}
|
}
|
||||||
"metrics" => run_metrics(),
|
"metrics" => {
|
||||||
|
let dry_run = args.contains("--dry-run");
|
||||||
|
args.finish()?;
|
||||||
|
MetricsCmd { dry_run }.run()
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"\
|
"\
|
||||||
|
|
|
@ -12,11 +12,21 @@ use crate::not_bash::{fs2, pushd, rm_rf, run};
|
||||||
|
|
||||||
type Unit = &'static str;
|
type Unit = &'static str;
|
||||||
|
|
||||||
pub fn run_metrics() -> Result<()> {
|
pub struct MetricsCmd {
|
||||||
let mut metrics = Metrics::new()?;
|
pub dry_run: bool,
|
||||||
metrics.measure_build()?;
|
}
|
||||||
|
|
||||||
{
|
impl MetricsCmd {
|
||||||
|
pub fn run(self) -> Result<()> {
|
||||||
|
let mut metrics = Metrics::new()?;
|
||||||
|
if !self.dry_run {
|
||||||
|
rm_rf("./target/release")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
metrics.measure_build()?;
|
||||||
|
metrics.measure_analysis_stats_self()?;
|
||||||
|
|
||||||
|
if !self.dry_run {
|
||||||
let _d = pushd("target");
|
let _d = pushd("target");
|
||||||
let metrics_token = env::var("METRICS_TOKEN").unwrap();
|
let metrics_token = env::var("METRICS_TOKEN").unwrap();
|
||||||
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
|
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
|
||||||
|
@ -32,16 +42,23 @@ pub fn run_metrics() -> Result<()> {
|
||||||
eprintln!("{:#?}", metrics);
|
eprintln!("{:#?}", metrics);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Metrics {
|
impl Metrics {
|
||||||
fn measure_build(&mut self) -> Result<()> {
|
fn measure_build(&mut self) -> Result<()> {
|
||||||
run!("cargo fetch")?;
|
run!("cargo fetch")?;
|
||||||
rm_rf("./target/release")?;
|
|
||||||
|
|
||||||
let build = Instant::now();
|
let time = Instant::now();
|
||||||
run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?;
|
run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?;
|
||||||
let build = build.elapsed();
|
let time = time.elapsed();
|
||||||
self.report("build", build.as_millis() as u64, "ms");
|
self.report("build", time.as_millis() as u64, "ms");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn measure_analysis_stats_self(&mut self) -> Result<()> {
|
||||||
|
let time = Instant::now();
|
||||||
|
run!("./target/release/rust-analyzer analysis-stats .")?;
|
||||||
|
let time = time.elapsed();
|
||||||
|
self.report("analysis-stats/self", time.as_millis() as u64, "ms");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue