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 @@ pub(crate) fn run(self) -> Result<()> {
}
{
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");
@ -108,6 +109,7 @@ struct Metrics {
host: Host,
timestamp: SystemTime,
revision: String,
perf_revision: String,
metrics: BTreeMap<String, (u64, Unit)>,
}
@ -123,7 +125,8 @@ fn new() -> Result<Metrics> {
let host = Host::new()?;
let timestamp = SystemTime::now();
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) {
@ -141,6 +144,7 @@ fn to_json(&self, mut obj: write_json::Object<'_>) {
let timestamp = self.timestamp.duration_since(UNIX_EPOCH).unwrap();
obj.number("timestamp", timestamp.as_secs() as f64);
obj.string("revision", &self.revision);
obj.string("perf_revision", &self.perf_revision);
let mut metrics = obj.object("metrics");
for (k, (value, unit)) in &self.metrics {
metrics.array(k).number(*value as f64).string(unit);