clap/clap_bench/benches/empty.rs
2024-05-14 12:27:02 -05:00

35 lines
618 B
Rust

#![allow(elided_lifetimes_in_paths)] // needed for divan
use clap::ArgMatches;
use clap::Command;
macro_rules! create_app {
() => {{
Command::new("claptests")
}};
}
#[divan::bench]
fn build() -> Command {
create_app!()
}
#[divan::bench]
fn startup() -> ArgMatches {
create_app!().get_matches_from(vec![""])
}
#[divan::bench]
fn render_help(bencher: divan::Bencher) {
let mut cmd = create_app!();
bencher.bench_local(|| build_help(&mut cmd));
}
fn build_help(cmd: &mut Command) -> String {
let help = cmd.render_help();
help.to_string()
}
fn main() {
divan::main();
}