From 81a2eaa92a221f754455e3abd0ec3939ae06cafe Mon Sep 17 00:00:00 2001
From: Douglas Weber <douglas.web@web.de>
Date: Mon, 15 Mar 2021 22:21:02 +0100
Subject: Add perf_revision to benchmark results

---
 xtask/src/metrics.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'xtask/src')

diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs
index 3d8d7589b..97395738b 100644
--- a/xtask/src/metrics.rs
+++ b/xtask/src/metrics.rs
@@ -26,7 +26,8 @@ impl flags::Metrics {
         }
         {
             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 @@ impl 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 @@ impl Metrics {
         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);
-- 
cgit v1.2.3