Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Feb 21, 2020
1 parent 922eb8f commit b5994d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
4 changes: 3 additions & 1 deletion benches/01_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
73 changes: 41 additions & 32 deletions benches/02_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b5994d1

Please sign in to comment.