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">
</p>
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

View File

@ -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!(
"\

View File

@ -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(())
}
}