8042: Add perf_revision to benchmark results r=lnicola a=d2weber

I gave it a try to add the hash as described in #8031 
Feel free to tell me if there is something I could improve.

Co-authored-by: Douglas Weber <douglas.web@web.de>
This commit is contained in:
bors[bot] 2021-03-16 19:36:55 +00:00 committed by GitHub
commit 9caeef98e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,8 @@ impl flags::Metrics {
} }
{ {
let _d = pushd("./target/rustc-perf")?; let _d = pushd("./target/rustc-perf")?;
cmd!("git reset --hard c52ee623e231e7690a93be88d943016968c1036b").run()?; let revision = &metrics.perf_revision;
cmd!("git reset --hard {revision}").run()?;
} }
let _env = pushenv("RA_METRICS", "1"); let _env = pushenv("RA_METRICS", "1");
@ -108,6 +109,7 @@ struct Metrics {
host: Host, host: Host,
timestamp: SystemTime, timestamp: SystemTime,
revision: String, revision: String,
perf_revision: String,
metrics: BTreeMap<String, (u64, Unit)>, metrics: BTreeMap<String, (u64, Unit)>,
} }
@ -123,7 +125,8 @@ impl Metrics {
let host = Host::new()?; let host = Host::new()?;
let timestamp = SystemTime::now(); let timestamp = SystemTime::now();
let revision = cmd!("git rev-parse HEAD").read()?; let revision = cmd!("git rev-parse HEAD").read()?;
Ok(Metrics { host, timestamp, revision, metrics: BTreeMap::new() }) let perf_revision = "c52ee623e231e7690a93be88d943016968c1036b".into();
Ok(Metrics { host, timestamp, revision, perf_revision, metrics: BTreeMap::new() })
} }
fn report(&mut self, name: &str, value: u64, unit: Unit) { fn report(&mut self, name: &str, value: u64, unit: Unit) {
@ -141,6 +144,7 @@ impl Metrics {
let timestamp = self.timestamp.duration_since(UNIX_EPOCH).unwrap(); let timestamp = self.timestamp.duration_since(UNIX_EPOCH).unwrap();
obj.number("timestamp", timestamp.as_secs() as f64); obj.number("timestamp", timestamp.as_secs() as f64);
obj.string("revision", &self.revision); obj.string("revision", &self.revision);
obj.string("perf_revision", &self.perf_revision);
let mut metrics = obj.object("metrics"); let mut metrics = obj.object("metrics");
for (k, (value, unit)) in &self.metrics { for (k, (value, unit)) in &self.metrics {
metrics.array(k).number(*value as f64).string(unit); metrics.array(k).number(*value as f64).string(unit);