Skip to content

Commit 24b6b2d

Browse files
Merge pull request #1064 from rylev/check-measureme-tooling
Check for measureme tooling before proceeding
2 parents ac6c94c + 6324e43 commit 24b6b2d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

collector/src/main.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,10 @@ fn bench(
225225
artifact_id, compiler.triple
226226
);
227227

228-
let has_measureme = Command::new("summarize").output().is_ok();
229228
if is_self_profile {
230-
assert!(
231-
has_measureme,
232-
"needs `summarize` in PATH for self profile.\n\
233-
Omit --self-profile` to opt out"
234-
);
229+
if let Err(e) = check_measureme_installed() {
230+
panic!("{}Or omit --self-profile` to opt out\n", e);
231+
}
235232
}
236233

237234
let steps = benchmarks
@@ -323,6 +320,21 @@ fn bench(
323320
errors
324321
}
325322

323+
fn check_measureme_installed() -> Result<(), String> {
324+
let mut binaries = vec![];
325+
326+
for name in ["summarize", "crox", "flamegraph"] {
327+
if let Err(_) = Command::new(name).output() {
328+
binaries.push(name);
329+
}
330+
}
331+
if binaries.is_empty() {
332+
Ok(())
333+
} else {
334+
Err(format!("To run this command you need {0} on your PATH. To install run `cargo install --git https://github.com/rust-lang/measureme --branch stable {0}`\n", binaries.join(" ")))
335+
}
336+
}
337+
326338
fn get_benchmarks(
327339
benchmark_dir: &Path,
328340
include: Option<&str>,
@@ -619,6 +631,9 @@ fn profile(
619631
errors: &mut BenchmarkErrors,
620632
) {
621633
eprintln!("Profiling {} with {:?}", id, profiler);
634+
if let Profiler::SelfProfile = profiler {
635+
check_measureme_installed().unwrap();
636+
}
622637
for (i, benchmark) in benchmarks.iter().enumerate() {
623638
eprintln!("{}", n_benchmarks_remaining(benchmarks.len() - i));
624639
let mut processor = execute::ProfileProcessor::new(profiler, out_dir, id);

0 commit comments

Comments
 (0)