Skip to content

Commit

Permalink
Store path to profiling output as PathBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Dec 16, 2024
1 parent 53ddd90 commit 4a88601
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/bin/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ fn main() -> anyhow::Result<()> {
opt.graph.check()?;

let workload = if let Some(perf_file) = opt.perf_file {
let path = perf_file.to_str().unwrap();
Workload::ReadPerf(path.to_string())
Workload::ReadPerf(perf_file)
} else {
match (opt.pid, opt.trailing_arguments.is_empty()) {
(Some(p), true) => Workload::Pid(p),
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use inferno::{collapse::Collapse, flamegraph::color::Palette, flamegraph::from_r
pub enum Workload {
Command(Vec<String>),
Pid(u32),
ReadPerf(String),
ReadPerf(PathBuf),
}

#[cfg(target_os = "linux")]
Expand All @@ -49,7 +49,7 @@ mod arch {
custom_cmd: Option<String>,
verbose: bool,
ignore_status: bool,
) -> Option<String> {
) -> Option<PathBuf> {
let perf = if let Ok(path) = env::var("PERF") {
path
} else {
Expand All @@ -76,7 +76,7 @@ mod arch {
if arg == "-o" {
let next_arg = args.next().expect("missing '-o' argument");
command.arg(next_arg);
perf_output = Some(next_arg.to_string());
perf_output = Some(PathBuf::from(next_arg));
}
}

Expand All @@ -96,7 +96,7 @@ mod arch {
}

pub fn output(
perf_output: Option<String>,
perf_output: Option<PathBuf>,
script_no_inline: bool,
sudo: Option<Option<&str>>,
) -> anyhow::Result<Vec<u8>> {
Expand Down Expand Up @@ -188,7 +188,7 @@ mod arch {
custom_cmd: Option<String>,
verbose: bool,
ignore_status: bool,
) -> Option<String> {
) -> Option<PathBuf> {
let mut command = base_dtrace_command(sudo);

let dtrace_script = custom_cmd.unwrap_or(format!(
Expand Down Expand Up @@ -261,7 +261,7 @@ mod arch {
}

pub fn output(
_: Option<String>,
_: Option<PathBuf>,
script_no_inline: bool,
sudo: Option<Option<&str>>,
) -> anyhow::Result<Vec<u8>> {
Expand Down

0 comments on commit 4a88601

Please sign in to comment.