mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 13:52:34 +00:00
35 lines
618 B
Rust
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();
|
|
}
|