From b83dcfe6130c9c21d1477062cdb42b5005c2e0ba Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 18 Dec 2024 14:42:53 +0100 Subject: [PATCH] store the creation timestamp of the benchmarked commit --- benchmarker/src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/benchmarker/src/main.rs b/benchmarker/src/main.rs index 109130c..1317bee 100644 --- a/benchmarker/src/main.rs +++ b/benchmarker/src/main.rs @@ -18,6 +18,9 @@ struct Commands(BTreeMap>); struct BenchData { // What and when are we benchmarking commit_hash: String, + commit_timestamp: u64, + + // timestamp when the benchmark was started timestamp: SystemTime, // Where are we benchmarking it on @@ -168,8 +171,26 @@ fn get_cpu_model() -> String { } fn main() { + let (commit_hash, commit_timestamp) = { + match env::var("GITHUB_SHA") { + Ok(sha) => { + // git show 27b31a568651dd725488e422e854095639d75af6 --no-patch --pretty=format:"%ct" + let output = Command::new("git") + .args(&["show", &sha, "--no-patch", "--pretty=format:\"%ct\""]) + .output() + .unwrap(); + + let timestamp: u64 = String::from_utf8_lossy(&output.stdout).parse().unwrap(); + + (sha, timestamp) + } + Err(_) => (String::new(), 0), + } + }; + let mut bench_data = BenchData { - commit_hash: env::var("GITHUB_SHA").unwrap_or_default(), + commit_hash, + commit_timestamp, timestamp: SystemTime::now(), arch: env::var("RUNNER_ARCH").unwrap_or_default(),