From 45b78482f5b9f72bb8bac9a1eec3b6a5cd232ed8 Mon Sep 17 00:00:00 2001 From: Nia Date: Mon, 3 Nov 2025 18:36:33 +0100 Subject: [PATCH] perf: Fixup Hyperfine finding (#41837) Release Notes: - N/A --- tooling/perf/src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tooling/perf/src/main.rs b/tooling/perf/src/main.rs index 1e6ddedf11e2c5f265d3d4dd93785afbf7f565d2..243658e50807aa71c25c279dda637f4db9b64766 100644 --- a/tooling/perf/src/main.rs +++ b/tooling/perf/src/main.rs @@ -413,10 +413,26 @@ fn triage_test( } } +/// Try to find the hyperfine binary the user has installed. +fn hyp_binary() -> Option { + const HYP_PATH: &str = "hyperfine"; + const HYP_HOME: &str = "~/.cargo/bin/hyperfine"; + if Command::new(HYP_PATH).output().is_err() { + if Command::new(HYP_HOME).output().is_err() { + None + } else { + Some(Command::new(HYP_HOME)) + } + } else { + Some(Command::new(HYP_PATH)) + } +} + /// Profiles a given test with hyperfine, returning the mean and standard deviation /// for its runtime. If the test errors, returns `None` instead. fn hyp_profile(t_bin: &str, t_name: &str, iterations: NonZero) -> Option { - let mut perf_cmd = Command::new("hyperfine"); + let mut perf_cmd = hyp_binary().expect("Couldn't find the Hyperfine binary on the system"); + // Warm up the cache and print markdown output to stdout, which we parse. perf_cmd.args([ "--style",