Skip to content

Commit

Permalink
feat: check if perf is installed (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
RRRadicalEdward authored Apr 15, 2024
1 parent 615752e commit 5a7cbe7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ mod arch {
verbose: bool,
ignore_status: bool,
) -> Option<String> {
let perf = env::var("PERF").unwrap_or_else(|_| "perf".to_string());
let perf = if let Ok(path) = env::var("PERF") {
path
} else {
if Command::new("perf").arg("--help").status().is_err() {
eprintln!("perf is not installed or not present in $PATH");
exit(1);
}

String::from("perf")
};
let mut command = sudo_command(&perf, sudo);

let args = custom_cmd.unwrap_or(format!("record -F {freq} --call-graph dwarf,16384 -g"));
Expand Down

0 comments on commit 5a7cbe7

Please sign in to comment.