Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ pub struct CpuProfFlags {
pub name: Option<String>,
pub interval: Option<u32>,
pub md: bool,
pub flamegraph: bool,
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Default, Debug, Eq, PartialEq)]
pub struct EvalFlags {
pub print: bool,
pub code: String,
Expand Down Expand Up @@ -5548,6 +5549,7 @@ fn cpu_prof_args(cmd: Command) -> Command {
.arg(cpu_prof_name_arg())
.arg(cpu_prof_interval_arg())
.arg(cpu_prof_md_arg())
.arg(cpu_prof_flamegraph_arg())
}

fn cpu_prof_parse(matches: &mut ArgMatches) -> Option<CpuProfFlags> {
Expand All @@ -5556,12 +5558,20 @@ fn cpu_prof_parse(matches: &mut ArgMatches) -> Option<CpuProfFlags> {
let name = matches.remove_one::<String>("cpu-prof-name");
let interval = matches.remove_one::<u32>("cpu-prof-interval");
let md = matches.get_flag("cpu-prof-md");
if enabled || dir.is_some() || name.is_some() || interval.is_some() || md {
let flamegraph = matches.get_flag("cpu-prof-flamegraph");
if enabled
|| dir.is_some()
|| name.is_some()
|| interval.is_some()
|| md
|| flamegraph
{
Some(CpuProfFlags {
dir,
name,
interval,
md,
flamegraph,
})
} else {
None
Expand Down Expand Up @@ -5607,6 +5617,13 @@ fn cpu_prof_md_arg() -> Arg {
.action(ArgAction::SetTrue)
}

fn cpu_prof_flamegraph_arg() -> Arg {
Arg::new("cpu-prof-flamegraph")
.long("cpu-prof-flamegraph")
.help("Generate an SVG flamegraph alongside the CPU profile")
.action(ArgAction::SetTrue)
}

fn permit_no_files_arg() -> Arg {
Arg::new("permit-no-files")
.long("permit-no-files")
Expand Down
4 changes: 4 additions & 0 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,10 @@ impl CliOptions {
self.flags.cpu_prof.as_ref().is_some_and(|f| f.md)
}

pub fn cpu_prof_flamegraph(&self) -> bool {
self.flags.cpu_prof.as_ref().is_some_and(|f| f.flamegraph)
}

pub fn enable_testing_features(&self) -> bool {
self.flags.enable_testing_features
}
Expand Down
2 changes: 2 additions & 0 deletions cli/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ impl CliFactory {
name: cli_options.cpu_prof_name(),
interval: cli_options.cpu_prof_interval(),
md: cli_options.cpu_prof_md(),
flamegraph: cli_options.cpu_prof_flamegraph(),
});

let lib_main_worker_factory = LibMainWorkerFactory::new(
Expand Down Expand Up @@ -1238,6 +1239,7 @@ impl CliFactory {
name: cli_options.cpu_prof_name(),
interval: cli_options.cpu_prof_interval(),
md: cli_options.cpu_prof_md(),
flamegraph: cli_options.cpu_prof_flamegraph(),
});

let initial_cwd =
Expand Down
1 change: 1 addition & 0 deletions cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl CliMainWorker {
filename,
config.interval,
config.md,
config.flamegraph,
);
cpu_profiler.start_profiling();

Expand Down
Loading
Loading