Skip to content

Commit 45b7848

Browse files
authored
perf: Fixup Hyperfine finding (#41837)
Release Notes: - N/A
1 parent 71f1f37 commit 45b7848

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tooling/perf/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,26 @@ fn triage_test(
413413
}
414414
}
415415

416+
/// Try to find the hyperfine binary the user has installed.
417+
fn hyp_binary() -> Option<Command> {
418+
const HYP_PATH: &str = "hyperfine";
419+
const HYP_HOME: &str = "~/.cargo/bin/hyperfine";
420+
if Command::new(HYP_PATH).output().is_err() {
421+
if Command::new(HYP_HOME).output().is_err() {
422+
None
423+
} else {
424+
Some(Command::new(HYP_HOME))
425+
}
426+
} else {
427+
Some(Command::new(HYP_PATH))
428+
}
429+
}
430+
416431
/// Profiles a given test with hyperfine, returning the mean and standard deviation
417432
/// for its runtime. If the test errors, returns `None` instead.
418433
fn hyp_profile(t_bin: &str, t_name: &str, iterations: NonZero<usize>) -> Option<Timings> {
419-
let mut perf_cmd = Command::new("hyperfine");
434+
let mut perf_cmd = hyp_binary().expect("Couldn't find the Hyperfine binary on the system");
435+
420436
// Warm up the cache and print markdown output to stdout, which we parse.
421437
perf_cmd.args([
422438
"--style",

0 commit comments

Comments
 (0)