mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
rustfmt
This commit is contained in:
parent
8ca1c22981
commit
edcb84b3c1
2 changed files with 44 additions and 33 deletions
|
@ -6,7 +6,9 @@ pub fn empty_app(c: &mut Criterion) {
|
|||
}
|
||||
|
||||
pub fn parse_clean(c: &mut Criterion) {
|
||||
c.bench_function("parse_clean", |b| b.iter(|| App::new("claptests").get_matches_from(vec![""])));
|
||||
c.bench_function("parse_clean", |b| {
|
||||
b.iter(|| App::new("claptests").get_matches_from(vec![""]))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, empty_app, parse_clean);
|
||||
|
|
|
@ -18,67 +18,76 @@ pub fn build_app(c: &mut Criterion) {
|
|||
}
|
||||
|
||||
pub fn add_flag(c: &mut Criterion) {
|
||||
c.bench_function("add_flag", |b| b.iter(|| {
|
||||
App::new("claptests").arg(Arg::from("-s, --some 'something'"))
|
||||
}));
|
||||
c.bench_function("add_flag", |b| {
|
||||
b.iter(|| App::new("claptests").arg(Arg::from("-s, --some 'something'")))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn add_flag_ref(c: &mut Criterion) {
|
||||
c.bench_function("add_flag_ref", |b| b.iter(|| {
|
||||
let arg = Arg::from("-s, --some 'something'");
|
||||
App::new("claptests").arg(&arg)
|
||||
}));
|
||||
c.bench_function("add_flag_ref", |b| {
|
||||
b.iter(|| {
|
||||
let arg = Arg::from("-s, --some 'something'");
|
||||
App::new("claptests").arg(&arg)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn add_opt(c: &mut Criterion) {
|
||||
c.bench_function("add_opt", |b| b.iter(|| {
|
||||
App::new("claptests").arg(Arg::from("-s, --some <FILE> 'something'"))
|
||||
}));
|
||||
c.bench_function("add_opt", |b| {
|
||||
b.iter(|| App::new("claptests").arg(Arg::from("-s, --some <FILE> 'something'")))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn add_opt_ref(c: &mut Criterion) {
|
||||
c.bench_function("add_opt_ref", |b| b.iter(|| {
|
||||
let arg = Arg::from("-s, --some <FILE> 'something'");
|
||||
App::new("claptests").arg(&arg)
|
||||
}));
|
||||
c.bench_function("add_opt_ref", |b| {
|
||||
b.iter(|| {
|
||||
let arg = Arg::from("-s, --some <FILE> 'something'");
|
||||
App::new("claptests").arg(&arg)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn add_pos(c: &mut Criterion) {
|
||||
c.bench_function("add_pos", |b| b.iter(|| App::new("claptests").arg(Arg::with_name("some"))));
|
||||
c.bench_function("add_pos", |b| {
|
||||
b.iter(|| App::new("claptests").arg(Arg::with_name("some")))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn add_pos_ref(c: &mut Criterion) {
|
||||
c.bench_function("add_pos_ref", |b| b.iter(|| {
|
||||
let arg = Arg::with_name("some");
|
||||
App::new("claptests").arg(&arg)
|
||||
}));
|
||||
c.bench_function("add_pos_ref", |b| {
|
||||
b.iter(|| {
|
||||
let arg = Arg::with_name("some");
|
||||
App::new("claptests").arg(&arg)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn parse_flag(c: &mut Criterion) {
|
||||
c.bench_function("parse_flag", |b| b.iter(|| {
|
||||
create_app!().get_matches_from(vec!["myprog", "-f"])
|
||||
}));
|
||||
c.bench_function("parse_flag", |b| {
|
||||
b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"]))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn parse_option(c: &mut Criterion) {
|
||||
c.bench_function("parse_option", |b| b.iter(|| {
|
||||
create_app!().get_matches_from(vec!["myprog", "-o", "option1"])
|
||||
}));
|
||||
c.bench_function("parse_option", |b| {
|
||||
b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1"]))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn parse_positional(c: &mut Criterion) {
|
||||
c.bench_function("parse_positional", |b| b.iter(|| {
|
||||
create_app!().get_matches_from(vec!["myprog", "arg1"])
|
||||
}));
|
||||
c.bench_function("parse_positional", |b| {
|
||||
b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"]))
|
||||
});
|
||||
}
|
||||
|
||||
pub fn parse_complex(c: &mut Criterion) {
|
||||
c.bench_function("parse_complex", |b| b.iter(|| {
|
||||
create_app!().get_matches_from(vec!["myprog", "-o", "option1", "-f", "arg1"])
|
||||
}));
|
||||
c.bench_function("parse_complex", |b| {
|
||||
b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1", "-f", "arg1"]))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches,
|
||||
criterion_group!(
|
||||
benches,
|
||||
parse_complex,
|
||||
parse_positional,
|
||||
parse_option,
|
||||
|
|
Loading…
Reference in a new issue