From 101cdc57c2eaec7c98213cf8babcad6c6342a144 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Jul 2020 00:16:21 +0200 Subject: [PATCH 1/2] Add self-analysis-stats to metrics --- xtask/src/main.rs | 8 +++++-- xtask/src/metrics.rs | 57 ++++++++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 6049542692b..b69b884e546 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -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!( "\ diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 9567f18f0a9..6c042d69513 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs @@ -12,36 +12,53 @@ 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, +} - { - let _d = pushd("target"); - let metrics_token = env::var("METRICS_TOKEN").unwrap(); - let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token); - run!("git clone --depth 1 {}", repo)?; - let _d = pushd("metrics"); +impl MetricsCmd { + pub fn run(self) -> Result<()> { + let mut metrics = Metrics::new()?; + if !self.dry_run { + rm_rf("./target/release")?; + } - let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?; - writeln!(file, "{}", metrics.json())?; - run!("git add .")?; - run!("git -c user.name=Bot -c user.email=dummy@example.com commit --message 📈")?; - run!("git push origin master")?; + 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); + run!("git clone --depth 1 {}", repo)?; + let _d = pushd("metrics"); + + let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?; + writeln!(file, "{}", metrics.json())?; + run!("git add .")?; + run!("git -c user.name=Bot -c user.email=dummy@example.com commit --message 📈")?; + run!("git push origin master")?; + } + eprintln!("{:#?}", metrics); + Ok(()) } - 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(()) } } From 2aa9d4a699c666b1305e4fd33b6a7861b227a4dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Jul 2020 00:18:21 +0200 Subject: [PATCH 2/2] Link metrics --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7ba705e7379..16c980400cf 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,8 @@ rust-analyzer logo

-rust-analyzer is an **experimental** modular compiler frontend for the Rust -language. It is a part of a larger rls-2.0 effort to create excellent IDE -support for Rust. If you want to get involved, check the rls-2.0 working group: - -https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 +rust-analyzer is an **experimental** modular compiler frontend for the Rust language. +It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust. Work on rust-analyzer is sponsored by @@ -25,8 +22,8 @@ If you want to **contribute** to rust-analyzer or are just curious about how things work under the hood, check the [./docs/dev](./docs/dev) folder. If you want to **use** rust-analyzer's language server with your editor of -choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. It also contains some tips & tricks to help -you be more productive when using rust-analyzer. +choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. +It also contains some tips & tricks to help you be more productive when using rust-analyzer. ## Communication @@ -40,8 +37,9 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 ## Quick Links -* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ * Website: https://rust-analyzer.github.io/ +* Metrics: https://rust-analyzer.github.io/metrics/ +* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ ## License