diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-24 23:18:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-24 23:18:45 +0100 |
commit | 0a4e90c0f855df29eb60445bf68ab959c59914ed (patch) | |
tree | 74bb0e9ccaec846efcbcd959a6de69aedc45ac5e | |
parent | a09a00a56049c705dcddc33773a27d5ce976b02e (diff) | |
parent | 2aa9d4a699c666b1305e4fd33b6a7861b227a4dc (diff) |
Merge #5527
5527: Link metrics r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | xtask/src/main.rs | 8 | ||||
-rw-r--r-- | xtask/src/metrics.rs | 63 |
3 files changed, 52 insertions, 33 deletions
@@ -2,11 +2,8 @@ | |||
2 | <img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo"> | 2 | <img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo"> |
3 | </p> | 3 | </p> |
4 | 4 | ||
5 | rust-analyzer is an **experimental** modular compiler frontend for the Rust | 5 | rust-analyzer is an **experimental** modular compiler frontend for the Rust language. |
6 | language. It is a part of a larger rls-2.0 effort to create excellent IDE | 6 | It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust. |
7 | support for Rust. If you want to get involved, check the rls-2.0 working group: | ||
8 | |||
9 | https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | ||
10 | 7 | ||
11 | Work on rust-analyzer is sponsored by | 8 | Work on rust-analyzer is sponsored by |
12 | 9 | ||
@@ -25,8 +22,8 @@ If you want to **contribute** to rust-analyzer or are just curious about how | |||
25 | things work under the hood, check the [./docs/dev](./docs/dev) folder. | 22 | things work under the hood, check the [./docs/dev](./docs/dev) folder. |
26 | 23 | ||
27 | If you want to **use** rust-analyzer's language server with your editor of | 24 | If you want to **use** rust-analyzer's language server with your editor of |
28 | choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. It also contains some tips & tricks to help | 25 | choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. |
29 | you be more productive when using rust-analyzer. | 26 | It also contains some tips & tricks to help you be more productive when using rust-analyzer. |
30 | 27 | ||
31 | ## Communication | 28 | ## Communication |
32 | 29 | ||
@@ -40,8 +37,9 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 | |||
40 | 37 | ||
41 | ## Quick Links | 38 | ## Quick Links |
42 | 39 | ||
43 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ | ||
44 | * Website: https://rust-analyzer.github.io/ | 40 | * Website: https://rust-analyzer.github.io/ |
41 | * Metrics: https://rust-analyzer.github.io/metrics/ | ||
42 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ | ||
45 | 43 | ||
46 | ## License | 44 | ## License |
47 | 45 | ||
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 604954269..b69b884e5 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -15,7 +15,7 @@ use xtask::{ | |||
15 | codegen::{self, Mode}, | 15 | codegen::{self, Mode}, |
16 | dist::DistCmd, | 16 | dist::DistCmd, |
17 | install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, | 17 | install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, |
18 | metrics::run_metrics, | 18 | metrics::MetricsCmd, |
19 | not_bash::pushd, | 19 | not_bash::pushd, |
20 | pre_commit, project_root, | 20 | pre_commit, project_root, |
21 | release::{PromoteCmd, ReleaseCmd}, | 21 | release::{PromoteCmd, ReleaseCmd}, |
@@ -118,7 +118,11 @@ FLAGS: | |||
118 | args.finish()?; | 118 | args.finish()?; |
119 | DistCmd { nightly, client_version }.run() | 119 | DistCmd { nightly, client_version }.run() |
120 | } | 120 | } |
121 | "metrics" => run_metrics(), | 121 | "metrics" => { |
122 | let dry_run = args.contains("--dry-run"); | ||
123 | args.finish()?; | ||
124 | MetricsCmd { dry_run }.run() | ||
125 | } | ||
122 | _ => { | 126 | _ => { |
123 | eprintln!( | 127 | eprintln!( |
124 | "\ | 128 | "\ |
diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 9567f18f0..6c042d695 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs | |||
@@ -12,36 +12,53 @@ use crate::not_bash::{fs2, pushd, rm_rf, run}; | |||
12 | 12 | ||
13 | type Unit = &'static str; | 13 | type Unit = &'static str; |
14 | 14 | ||
15 | pub fn run_metrics() -> Result<()> { | 15 | pub struct MetricsCmd { |
16 | let mut metrics = Metrics::new()?; | 16 | pub dry_run: bool, |
17 | metrics.measure_build()?; | 17 | } |
18 | 18 | ||
19 | { | 19 | impl MetricsCmd { |
20 | let _d = pushd("target"); | 20 | pub fn run(self) -> Result<()> { |
21 | let metrics_token = env::var("METRICS_TOKEN").unwrap(); | 21 | let mut metrics = Metrics::new()?; |
22 | let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token); | 22 | if !self.dry_run { |
23 | run!("git clone --depth 1 {}", repo)?; | 23 | rm_rf("./target/release")?; |
24 | let _d = pushd("metrics"); | 24 | } |
25 | 25 | ||
26 | let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?; | 26 | metrics.measure_build()?; |
27 | writeln!(file, "{}", metrics.json())?; | 27 | metrics.measure_analysis_stats_self()?; |
28 | run!("git add .")?; | 28 | |
29 | run!("git -c user.name=Bot -c [email protected] commit --message 📈")?; | 29 | if !self.dry_run { |
30 | run!("git push origin master")?; | 30 | let _d = pushd("target"); |
31 | } | 31 | let metrics_token = env::var("METRICS_TOKEN").unwrap(); |
32 | eprintln!("{:#?}", metrics); | 32 | let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token); |
33 | Ok(()) | 33 | run!("git clone --depth 1 {}", repo)?; |
34 | let _d = pushd("metrics"); | ||
35 | |||
36 | let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?; | ||
37 | writeln!(file, "{}", metrics.json())?; | ||
38 | run!("git add .")?; | ||
39 | run!("git -c user.name=Bot -c [email protected] commit --message 📈")?; | ||
40 | run!("git push origin master")?; | ||
41 | } | ||
42 | eprintln!("{:#?}", metrics); | ||
43 | Ok(()) | ||
44 | } | ||
34 | } | 45 | } |
35 | 46 | ||
36 | impl Metrics { | 47 | impl Metrics { |
37 | fn measure_build(&mut self) -> Result<()> { | 48 | fn measure_build(&mut self) -> Result<()> { |
38 | run!("cargo fetch")?; | 49 | run!("cargo fetch")?; |
39 | rm_rf("./target/release")?; | ||
40 | 50 | ||
41 | let build = Instant::now(); | 51 | let time = Instant::now(); |
42 | run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?; | 52 | run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?; |
43 | let build = build.elapsed(); | 53 | let time = time.elapsed(); |
44 | self.report("build", build.as_millis() as u64, "ms"); | 54 | self.report("build", time.as_millis() as u64, "ms"); |
55 | Ok(()) | ||
56 | } | ||
57 | fn measure_analysis_stats_self(&mut self) -> Result<()> { | ||
58 | let time = Instant::now(); | ||
59 | run!("./target/release/rust-analyzer analysis-stats .")?; | ||
60 | let time = time.elapsed(); | ||
61 | self.report("analysis-stats/self", time.as_millis() as u64, "ms"); | ||
45 | Ok(()) | 62 | Ok(()) |
46 | } | 63 | } |
47 | } | 64 | } |