5527: Link metrics r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-24 22:18:45 +00:00 committed by GitHub
commit 0a4e90c0f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 30 deletions

View File

@ -2,11 +2,8 @@
<img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo"> <img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo">
</p> </p>
rust-analyzer is an **experimental** modular compiler frontend for the Rust rust-analyzer is an **experimental** modular compiler frontend for the Rust language.
language. It is a part of a larger rls-2.0 effort to create excellent IDE It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
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
Work on rust-analyzer is sponsored by 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. 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 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 choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder.
you be more productive when using rust-analyzer. It also contains some tips & tricks to help you be more productive when using rust-analyzer.
## Communication ## Communication
@ -40,8 +37,9 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0
## Quick Links ## Quick Links
* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/
* Website: https://rust-analyzer.github.io/ * 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 ## License

View File

@ -15,7 +15,7 @@
codegen::{self, Mode}, codegen::{self, Mode},
dist::DistCmd, dist::DistCmd,
install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, install::{ClientOpt, InstallCmd, Malloc, ServerOpt},
metrics::run_metrics, metrics::MetricsCmd,
not_bash::pushd, not_bash::pushd,
pre_commit, project_root, pre_commit, project_root,
release::{PromoteCmd, ReleaseCmd}, release::{PromoteCmd, ReleaseCmd},
@ -118,7 +118,11 @@ fn main() -> Result<()> {
args.finish()?; args.finish()?;
DistCmd { nightly, client_version }.run() DistCmd { nightly, client_version }.run()
} }
"metrics" => run_metrics(), "metrics" => {
let dry_run = args.contains("--dry-run");
args.finish()?;
MetricsCmd { dry_run }.run()
}
_ => { _ => {
eprintln!( eprintln!(
"\ "\

View File

@ -12,11 +12,21 @@
type Unit = &'static str; type Unit = &'static str;
pub fn run_metrics() -> Result<()> { pub struct MetricsCmd {
let mut metrics = Metrics::new()?; pub dry_run: bool,
metrics.measure_build()?; }
{ 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 _d = pushd("target");
let metrics_token = env::var("METRICS_TOKEN").unwrap(); let metrics_token = env::var("METRICS_TOKEN").unwrap();
let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token); let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", metrics_token);
@ -32,16 +42,23 @@ pub fn run_metrics() -> Result<()> {
eprintln!("{:#?}", metrics); eprintln!("{:#?}", metrics);
Ok(()) Ok(())
} }
}
impl Metrics { impl Metrics {
fn measure_build(&mut self) -> Result<()> { fn measure_build(&mut self) -> Result<()> {
run!("cargo fetch")?; 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")?; run!("cargo build --release --package rust-analyzer --bin rust-analyzer")?;
let build = build.elapsed(); let time = time.elapsed();
self.report("build", build.as_millis() as u64, "ms"); 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(()) Ok(())
} }
} }