with perf

This commit is contained in:
Kasper Juul Hermansen 2022-12-18 15:06:12 +01:00
parent 45f617d7b5
commit bd52a2d3bb
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23
2 changed files with 32 additions and 0 deletions

View File

@ -1,5 +1,6 @@
mod code; mod code;
mod network; mod network;
mod perf;
mod procs; mod procs;
mod storage; mod storage;
@ -19,6 +20,7 @@ impl util::Cmd for Stats {
network::Network::cmd()?, network::Network::cmd()?,
procs::Procs::cmd()?, procs::Procs::cmd()?,
storage::Storage::cmd()?, storage::Storage::cmd()?,
perf::Perf::cmd()?,
]) ])
.subcommand_required(true); .subcommand_required(true);
@ -31,6 +33,7 @@ impl util::Cmd for Stats {
Some(("network", args)) => network::Network::exec(args), Some(("network", args)) => network::Network::exec(args),
Some(("procs", args)) => procs::Procs::exec(args), Some(("procs", args)) => procs::Procs::exec(args),
Some(("storage", args)) => storage::Storage::exec(args), Some(("storage", args)) => storage::Storage::exec(args),
Some(("perf", args)) => perf::Perf::exec(args),
_ => Stats::run(), _ => Stats::run(),
} }
} }

29
crates/stats/src/perf.rs Normal file
View File

@ -0,0 +1,29 @@
pub struct Perf;
impl Perf {
fn run() -> eyre::Result<()> {
if let Err(_) = util::shell::run_with_input_and_output(&["ytop", "--version"], "".into()) {
return Err(eyre::anyhow!(
"could not find ytop, please install or add to PATH"
));
}
util::shell::run(&["ytop"], None)?;
Ok(())
}
}
impl util::Cmd for Perf {
fn cmd() -> eyre::Result<clap::Command> {
let cmd = clap::Command::new("perf").subcommands(&[]);
Ok(cmd)
}
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
match args.subcommand() {
_ => Perf::run(),
}
}
}