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 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 @@ 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 @@ fn main() -> Result<()> { 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 @@ 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(()) } }