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},
|
||||
dist::DistCmd,
|
||||
install::{ClientOpt, InstallCmd, Malloc, ServerOpt},
|
||||
metrics::run_metrics,
|
||||
metrics::MetricsCmd,
|
||||
not_bash::pushd,
|
||||
pre_commit, project_root,
|
||||
release::{PromoteCmd, ReleaseCmd},
|
||||
|
@ -118,7 +118,11 @@ FLAGS:
|
|||
args.finish()?;
|
||||
DistCmd { nightly, client_version }.run()
|
||||
}
|
||||
"metrics" => run_metrics(),
|
||||
"metrics" => {
|
||||
let dry_run = args.contains("--dry-run");
|
||||
args.finish()?;
|
||||
MetricsCmd { dry_run }.run()
|
||||
}
|
||||
_ => {
|
||||
eprintln!(
|
||||
"\
|
||||
|
|
|
@ -12,11 +12,21 @@ use crate::not_bash::{fs2, pushd, rm_rf, run};
|
|||
|
||||
type Unit = &'static str;
|
||||
|
||||
pub fn run_metrics() -> Result<()> {
|
||||
let mut metrics = Metrics::new()?;
|
||||
metrics.measure_build()?;
|
||||
pub struct MetricsCmd {
|
||||
pub dry_run: bool,
|
||||
}
|
||||
|
||||
{
|
||||
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 metrics_token = env::var("METRICS_TOKEN").unwrap();
|
||||
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
|
||||
|
@ -31,17 +41,24 @@ pub fn run_metrics() -> Result<()> {
|
|||
}
|
||||
eprintln!("{:#?}", metrics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
fn measure_build(&mut self) -> Result<()> {
|
||||
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")?;
|
||||
let build = build.elapsed();
|
||||
self.report("build", build.as_millis() as u64, "ms");
|
||||
let time = time.elapsed();
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue