Skip to content

Commit 0a4e90c

Browse files
bors[bot]matklad
andauthored
Merge #5527
5527: Link metrics r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents a09a00a + 2aa9d4a commit 0a4e90c

File tree

3 files changed

+52
-33
lines changed

3 files changed

+52
-33
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
<img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo">
33
</p>
44

5-
rust-analyzer is an **experimental** modular compiler frontend for the Rust
6-
language. It is a part of a larger rls-2.0 effort to create excellent IDE
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
5+
rust-analyzer is an **experimental** modular compiler frontend for the Rust language.
6+
It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
107

118
Work on rust-analyzer is sponsored by
129

@@ -25,8 +22,8 @@ If you want to **contribute** to rust-analyzer or are just curious about how
2522
things work under the hood, check the [./docs/dev](./docs/dev) folder.
2623

2724
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
29-
you be more productive when using rust-analyzer.
25+
choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder.
26+
It also contains some tips & tricks to help you be more productive when using rust-analyzer.
3027

3128
## Communication
3229

@@ -40,8 +37,9 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0
4037

4138
## Quick Links
4239

43-
* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/
4440
* 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/
4543

4644
## License
4745

xtask/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use xtask::{
1515
codegen::{self, Mode},
1616
dist::DistCmd,
1717
install::{ClientOpt, InstallCmd, Malloc, ServerOpt},
18-
metrics::run_metrics,
18+
metrics::MetricsCmd,
1919
not_bash::pushd,
2020
pre_commit, project_root,
2121
release::{PromoteCmd, ReleaseCmd},
@@ -118,7 +118,11 @@ FLAGS:
118118
args.finish()?;
119119
DistCmd { nightly, client_version }.run()
120120
}
121-
"metrics" => run_metrics(),
121+
"metrics" => {
122+
let dry_run = args.contains("--dry-run");
123+
args.finish()?;
124+
MetricsCmd { dry_run }.run()
125+
}
122126
_ => {
123127
eprintln!(
124128
"\

xtask/src/metrics.rs

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,53 @@ use crate::not_bash::{fs2, pushd, rm_rf, run};
1212

1313
type Unit = &'static str;
1414

15-
pub fn run_metrics() -> Result<()> {
16-
let mut metrics = Metrics::new()?;
17-
metrics.measure_build()?;
18-
19-
{
20-
let _d = pushd("target");
21-
let metrics_token = env::var("METRICS_TOKEN").unwrap();
22-
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
23-
run!("git clone --depth 1 {}", repo)?;
24-
let _d = pushd("metrics");
25-
26-
let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?;
27-
writeln!(file, "{}", metrics.json())?;
28-
run!("git add .")?;
29-
run!("git -c user.name=Bot -c [email protected] commit --message 📈")?;
30-
run!("git push origin master")?;
31-
}
32-
eprintln!("{:#?}", metrics);
33-
Ok(())
15+
pub struct MetricsCmd {
16+
pub dry_run: bool,
17+
}
18+
19+
impl MetricsCmd {
20+
pub fn run(self) -> Result<()> {
21+
let mut metrics = Metrics::new()?;
22+
if !self.dry_run {
23+
rm_rf("./target/release")?;
24+
}
25+
26+
metrics.measure_build()?;
27+
metrics.measure_analysis_stats_self()?;
28+
29+
if !self.dry_run {
30+
let _d = pushd("target");
31+
let metrics_token = env::var("METRICS_TOKEN").unwrap();
32+
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
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+
}
3445
}
3546

3647
impl Metrics {
3748
fn measure_build(&mut self) -> Result<()> {
3849
run!("cargo fetch")?;
39-
rm_rf("./target/release")?;
4050

41-
let build = Instant::now();
51+
let time = Instant::now();
4252
run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?;
43-
let build = build.elapsed();
44-
self.report("build", build.as_millis() as u64, "ms");
53+
let time = time.elapsed();
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");
4562
Ok(())
4663
}
4764
}

0 commit comments

Comments
 (0)