mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 22:02:35 +00:00
tests: adds some minor benches for adding args by ref or moving
This commit is contained in:
parent
6f638a53c1
commit
6b58efa330
1 changed files with 64 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
extern crate clap;
|
||||
extern crate test;
|
||||
|
||||
use clap::App;
|
||||
use clap::{App, Arg};
|
||||
|
||||
use test::Bencher;
|
||||
|
||||
|
@ -25,6 +25,69 @@ fn build_app(b: &mut Bencher) {
|
|||
b.iter(|| create_app!());
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_flag(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| build_app().arg(Arg::from_usage("-s, --some 'something'")));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_flag_ref(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
let arg = Arg::from_usage("-s, --some 'something'");
|
||||
build_app().arg(&arg)
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_opt(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| build_app().arg(Arg::from_usage("-s, --some <FILE> 'something'")));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_opt_ref(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
let arg = Arg::from_usage("-s, --some <FILE> 'something'");
|
||||
build_app().arg(&arg)
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_pos(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| build_app().arg(Arg::with_name("some")));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn add_pos_ref(b: &mut Bencher) {
|
||||
fn build_app() -> App<'static, 'static> {
|
||||
App::new("claptests")
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
let arg = Arg::with_name("some");
|
||||
build_app().arg(&arg)
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn parse_clean(b: &mut Bencher) {
|
||||
b.iter(|| create_app!().get_matches_from(vec![""]));
|
||||
|
|
Loading…
Reference in a new issue