Skip to content

Commit 8963f87

Browse files
committed
Check for measureme tooling before proceeding
1 parent c768083 commit 8963f87

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 error = |name| {
325+
format!("To run this command you need the `{0}` binary on your PATH. To install run `cargo install --git https://github.com/rust-lang/measureme --branch stable {0}`\n", name)
326+
};
327+
Command::new("summarize")
328+
.output()
329+
.map_err(|_| error("summarize"))?;
330+
Command::new("crox").output().map_err(|_| error("crox"))?;
331+
Command::new("flamegraph")
332+
.output()
333+
.map_err(|_| error("flamegraph"))?;
334+
335+
Ok(())
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)