From 48605165551f26b3e4b8e87edec31d3f9e239771 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Thu, 5 Mar 2020 10:06:17 +0100 Subject: [PATCH] Shorten some of the benches names --- benches/01_default.rs | 10 +++--- benches/02_simple.rs | 66 ++++++++++++++++++------------------ benches/03_complex.rs | 78 +++++++++++++++++++++---------------------- benches/06_rustup.rs | 11 ++---- 4 files changed, 80 insertions(+), 85 deletions(-) diff --git a/benches/01_default.rs b/benches/01_default.rs index a513a3f9..07e3ad21 100644 --- a/benches/01_default.rs +++ b/benches/01_default.rs @@ -1,15 +1,15 @@ use clap::App; use criterion::{criterion_group, criterion_main, Criterion}; -pub fn build_empty_app(c: &mut Criterion) { - c.bench_function("build_empty_app", |b| b.iter(|| App::new("claptests"))); +pub fn build_empty(c: &mut Criterion) { + c.bench_function("build_empty", |b| b.iter(|| App::new("claptests"))); } -pub fn parse_empty_app(c: &mut Criterion) { - c.bench_function("parse_empty_app", |b| { +pub fn parse_empty(c: &mut Criterion) { + c.bench_function("parse_empty", |b| { b.iter(|| App::new("claptests").get_matches_from(vec![""])) }); } -criterion_group!(benches, build_empty_app, parse_empty_app); +criterion_group!(benches, build_empty, parse_empty); criterion_main!(benches); diff --git a/benches/02_simple.rs b/benches/02_simple.rs index 417483e9..3a1489b4 100644 --- a/benches/02_simple.rs +++ b/benches/02_simple.rs @@ -13,18 +13,18 @@ macro_rules! create_app { }}; } -pub fn build_simple_app(c: &mut Criterion) { - c.bench_function("build_simple_app", |b| b.iter(|| create_app!())); +pub fn build_simple(c: &mut Criterion) { + c.bench_function("build_simple", |b| b.iter(|| create_app!())); } -pub fn build_app_with_flag(c: &mut Criterion) { - c.bench_function("build_app_with_flag", |b| { +pub fn build_with_flag(c: &mut Criterion) { + c.bench_function("build_with_flag", |b| { b.iter(|| App::new("claptests").arg(Arg::from("-s, --some 'something'"))) }); } -pub fn build_app_with_flag_ref(c: &mut Criterion) { - c.bench_function("build_app_with_flag_ref", |b| { +pub fn build_with_flag_ref(c: &mut Criterion) { + c.bench_function("build_with_flag_ref", |b| { b.iter(|| { let arg = Arg::from("-s, --some 'something'"); App::new("claptests").arg(&arg) @@ -32,14 +32,14 @@ pub fn build_app_with_flag_ref(c: &mut Criterion) { }); } -pub fn build_app_with_opt(c: &mut Criterion) { - c.bench_function("build_app_with_opt", |b| { +pub fn build_with_opt(c: &mut Criterion) { + c.bench_function("build_with_opt", |b| { b.iter(|| App::new("claptests").arg(Arg::from("-s, --some 'something'"))) }); } -pub fn build_app_with_opt_ref(c: &mut Criterion) { - c.bench_function("build_app_with_opt_ref", |b| { +pub fn build_with_opt_ref(c: &mut Criterion) { + c.bench_function("build_with_opt_ref", |b| { b.iter(|| { let arg = Arg::from("-s, --some 'something'"); App::new("claptests").arg(&arg) @@ -47,14 +47,14 @@ pub fn build_app_with_opt_ref(c: &mut Criterion) { }); } -pub fn build_app_with_pos(c: &mut Criterion) { - c.bench_function("build_app_with_pos", |b| { +pub fn build_with_pos(c: &mut Criterion) { + c.bench_function("build_with_pos", |b| { b.iter(|| App::new("claptests").arg(Arg::with_name("some"))) }); } -pub fn build_app_with_pos_ref(c: &mut Criterion) { - c.bench_function("build_app_with_pos_ref", |b| { +pub fn build_with_pos_ref(c: &mut Criterion) { + c.bench_function("build_with_pos_ref", |b| { b.iter(|| { let arg = Arg::with_name("some"); App::new("claptests").arg(&arg) @@ -62,43 +62,43 @@ pub fn build_app_with_pos_ref(c: &mut Criterion) { }); } -pub fn parse_simple_app_with_flag(c: &mut Criterion) { - c.bench_function("parse_simple_app_with_flag", |b| { +pub fn parse_simple_with_flag(c: &mut Criterion) { + c.bench_function("parse_simple_with_flag", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"])) }); } -pub fn parse_simple_app_with_option(c: &mut Criterion) { - c.bench_function("parse_simple_app_with_option", |b| { +pub fn parse_simple_with_opt(c: &mut Criterion) { + c.bench_function("parse_simple_with_opt", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1"])) }); } -pub fn parse_simple_app_with_positional(c: &mut Criterion) { - c.bench_function("parse_simple_app_with_positional", |b| { +pub fn parse_simple_with_pos(c: &mut Criterion) { + c.bench_function("parse_simple_with_pos", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"])) }); } -pub fn parse_simple_app_with_complex(c: &mut Criterion) { - c.bench_function("parse_simple_app_with_complex", |b| { +pub fn parse_simple_with_complex(c: &mut Criterion) { + c.bench_function("parse_simple_with_complex", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1", "-f", "arg1"])) }); } criterion_group!( benches, - parse_simple_app_with_complex, - parse_simple_app_with_positional, - parse_simple_app_with_option, - parse_simple_app_with_flag, - build_app_with_pos_ref, - build_app_with_pos, - build_app_with_opt_ref, - build_app_with_opt, - build_app_with_flag_ref, - build_app_with_flag, - build_simple_app + parse_simple_with_complex, + parse_simple_with_pos, + parse_simple_with_opt, + parse_simple_with_flag, + build_with_pos_ref, + build_with_pos, + build_with_opt_ref, + build_with_opt, + build_with_flag_ref, + build_with_flag, + build_simple ); criterion_main!(benches); diff --git a/benches/03_complex.rs b/benches/03_complex.rs index b0b21d9b..0d440540 100644 --- a/benches/03_complex.rs +++ b/benches/03_complex.rs @@ -41,12 +41,12 @@ macro_rules! create_app { }}; } -pub fn build_app_from_usage(c: &mut Criterion) { - c.bench_function("build_app_from_usage", |b| b.iter(|| create_app!())); +pub fn build_from_usage(c: &mut Criterion) { + c.bench_function("build_from_usage", |b| b.iter(|| create_app!())); } -pub fn build_app_from_builder(c: &mut Criterion) { - c.bench_function("build_app_from_builder", |b| { +pub fn build_from_builder(c: &mut Criterion) { + c.bench_function("build_from_builder", |b| { b.iter(|| { App::new("claptests") .version("0.1") @@ -162,8 +162,8 @@ pub fn build_app_from_builder(c: &mut Criterion) { }); } -pub fn build_app_from_macros(c: &mut Criterion) { - c.bench_function("build_app_from_macros", |b| { +pub fn build_from_macros(c: &mut Criterion) { + c.bench_function("build_from_macros", |b| { b.iter(|| { clap_app!(claptests => (version: "0.1") @@ -198,50 +198,50 @@ pub fn build_app_from_macros(c: &mut Criterion) { }); } -pub fn parse_complex_app(c: &mut Criterion) { - c.bench_function("parse_complex_app", |b| { +pub fn parse_complex(c: &mut Criterion) { + c.bench_function("parse_complex", |b| { b.iter(|| create_app!().get_matches_from(vec![""])) }); } -pub fn parse_complex_app_with_flag(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_flag", |b| { +pub fn parse_complex_with_flag(c: &mut Criterion) { + c.bench_function("parse_complex_with_flag", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"])) }); } -pub fn parse_complex_app_with_option(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_option", |b| { +pub fn parse_complex_with_opt(c: &mut Criterion) { + c.bench_function("parse_complex_with_opt", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1"])) }); } -pub fn parse_complex_app_with_positional(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_positional", |b| { +pub fn parse_complex_with_pos(c: &mut Criterion) { + c.bench_function("parse_complex_with_pos", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"])) }); } -pub fn parse_complex_app_with_sc(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_sc", |b| { +pub fn parse_complex_with_sc(c: &mut Criterion) { + c.bench_function("parse_complex_with_sc", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd"])) }); } -pub fn parse_complex_app_with_sc_flag(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_sc_flag", |b| { +pub fn parse_complex_with_sc_flag(c: &mut Criterion) { + c.bench_function("parse_complex_with_sc_flag", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-f"])) }); } -pub fn parse_complex_app_with_sc_option(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_sc_option", |b| { +pub fn parse_complex_with_sc_opt(c: &mut Criterion) { + c.bench_function("parse_complex_with_sc_opt", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-o", "option1"])) }); } -pub fn parse_complex_app_with_sc_positional(c: &mut Criterion) { - c.bench_function("parse_complex_app_with_sc_positional", |b| { +pub fn parse_complex_with_sc_pos(c: &mut Criterion) { + c.bench_function("parse_complex_with_sc_pos", |b| { b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "arg1"])) }); } @@ -291,8 +291,8 @@ pub fn parse_complex2(c: &mut Criterion) { }); } -pub fn parse_complex2_with_args_negate_scs(c: &mut Criterion) { - c.bench_function("parse_complex2_with_args_negate_scs", |b| { +pub fn parse_args_negate_scs(c: &mut Criterion) { + c.bench_function("parse_args_negate_scs", |b| { b.iter(|| { create_app!() .setting(AppSettings::ArgsNegateSubcommands) @@ -317,8 +317,8 @@ pub fn parse_complex2_with_args_negate_scs(c: &mut Criterion) { }); } -pub fn parse_sc_complex(c: &mut Criterion) { - c.bench_function("parse_sc_complex", |b| { +pub fn parse_complex_with_sc_complex(c: &mut Criterion) { + c.bench_function("parse_complex_with_sc_complex", |b| { b.iter(|| { create_app!().get_matches_from(vec!["myprog", "subcmd", "-f", "-o", "option1", "arg1"]) }) @@ -327,21 +327,21 @@ pub fn parse_sc_complex(c: &mut Criterion) { criterion_group!( benches, - build_app_from_usage, - build_app_from_builder, - build_app_from_macros, - parse_complex_app, - parse_complex_app_with_flag, - parse_complex_app_with_option, - parse_complex_app_with_positional, - parse_complex_app_with_sc, - parse_complex_app_with_sc_flag, - parse_complex_app_with_sc_option, - parse_complex_app_with_sc_positional, + build_from_usage, + build_from_builder, + build_from_macros, + parse_complex, + parse_complex_with_flag, + parse_complex_with_opt, + parse_complex_with_pos, + parse_complex_with_sc, + parse_complex_with_sc_flag, + parse_complex_with_sc_opt, + parse_complex_with_sc_pos, parse_complex1, parse_complex2, - parse_complex2_with_args_negate_scs, - parse_sc_complex + parse_args_negate_scs, + parse_complex_with_sc_complex ); criterion_main!(benches); diff --git a/benches/06_rustup.rs b/benches/06_rustup.rs index 450d3fd5..a58bea4e 100644 --- a/benches/06_rustup.rs +++ b/benches/06_rustup.rs @@ -15,8 +15,8 @@ pub fn parse_rustup(c: &mut Criterion) { }); } -pub fn parse_rustup_with_subcommands(c: &mut Criterion) { - c.bench_function("parse_rustup_with_subcommands", |b| { +pub fn parse_rustup_with_sc(c: &mut Criterion) { + c.bench_function("parse_rustup_with_sc", |b| { b.iter(|| build_cli().get_matches_from(vec!["rustup override add stable"])) }); } @@ -455,11 +455,6 @@ default browser. By default, it opens the documentation index. Use the various flags to open specific pieces of documentation."; -criterion_group!( - benches, - build_rustup, - parse_rustup, - parse_rustup_with_subcommands -); +criterion_group!(benches, build_rustup, parse_rustup, parse_rustup_with_sc); criterion_main!(benches);