1719: Use GH actions/continuous_becnchmark r=CreepySkeleton a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
This commit is contained in:
bors[bot] 2020-03-04 19:07:48 +00:00 committed by GitHub
commit 3792941cb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 114 additions and 101 deletions

View file

@ -26,6 +26,9 @@ categories = ["command-line-interface"]
license = "MIT OR Apache-2.0"
readme = "README.md"
[lib]
bench = false
[[bench]]
harness = false
name = "01_default"

View file

@ -1,15 +1,15 @@
use clap::App;
use criterion::{criterion_group, criterion_main, Criterion};
pub fn empty_app(c: &mut Criterion) {
c.bench_function("build_app", |b| b.iter(|| App::new("claptests")));
pub fn build_empty_app(c: &mut Criterion) {
c.bench_function("build_empty_app", |b| b.iter(|| App::new("claptests")));
}
pub fn parse_clean(c: &mut Criterion) {
c.bench_function("parse_clean", |b| {
pub fn parse_empty_app(c: &mut Criterion) {
c.bench_function("parse_empty_app", |b| {
b.iter(|| App::new("claptests").get_matches_from(vec![""]))
});
}
criterion_group!(benches, empty_app, parse_clean);
criterion_group!(benches, build_empty_app, parse_empty_app);
criterion_main!(benches);

View file

@ -13,18 +13,18 @@ macro_rules! create_app {
}};
}
pub fn build_app(c: &mut Criterion) {
c.bench_function("build_app", |b| b.iter(|| create_app!()));
pub fn build_simple_app(c: &mut Criterion) {
c.bench_function("build_simple_app", |b| b.iter(|| create_app!()));
}
pub fn add_flag(c: &mut Criterion) {
c.bench_function("add_flag", |b| {
pub fn build_app_with_flag(c: &mut Criterion) {
c.bench_function("build_app_with_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| {
pub fn build_app_with_flag_ref(c: &mut Criterion) {
c.bench_function("build_app_with_flag_ref", |b| {
b.iter(|| {
let arg = Arg::from("-s, --some 'something'");
App::new("claptests").arg(&arg)
@ -32,14 +32,14 @@ pub fn add_flag_ref(c: &mut Criterion) {
});
}
pub fn add_opt(c: &mut Criterion) {
c.bench_function("add_opt", |b| {
pub fn build_app_with_opt(c: &mut Criterion) {
c.bench_function("build_app_with_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| {
pub fn build_app_with_opt_ref(c: &mut Criterion) {
c.bench_function("build_app_with_opt_ref", |b| {
b.iter(|| {
let arg = Arg::from("-s, --some <FILE> 'something'");
App::new("claptests").arg(&arg)
@ -47,14 +47,14 @@ pub fn add_opt_ref(c: &mut Criterion) {
});
}
pub fn add_pos(c: &mut Criterion) {
c.bench_function("add_pos", |b| {
pub fn build_app_with_pos(c: &mut Criterion) {
c.bench_function("build_app_with_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| {
pub fn build_app_with_pos_ref(c: &mut Criterion) {
c.bench_function("build_app_with_pos_ref", |b| {
b.iter(|| {
let arg = Arg::with_name("some");
App::new("claptests").arg(&arg)
@ -62,43 +62,43 @@ pub fn add_pos_ref(c: &mut Criterion) {
});
}
pub fn parse_flag(c: &mut Criterion) {
c.bench_function("parse_flag", |b| {
pub fn parse_simple_app_with_flag(c: &mut Criterion) {
c.bench_function("parse_simple_app_with_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| {
pub fn parse_simple_app_with_option(c: &mut Criterion) {
c.bench_function("parse_simple_app_with_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| {
pub fn parse_simple_app_with_positional(c: &mut Criterion) {
c.bench_function("parse_simple_app_with_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| {
pub fn parse_simple_app_with_complex(c: &mut Criterion) {
c.bench_function("parse_simple_app_with_complex", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1", "-f", "arg1"]))
});
}
criterion_group!(
benches,
parse_complex,
parse_positional,
parse_option,
parse_flag,
add_pos_ref,
add_pos,
add_opt_ref,
add_opt,
add_flag_ref,
add_flag,
build_app
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
);
criterion_main!(benches);

View file

@ -41,12 +41,12 @@ macro_rules! create_app {
}};
}
pub fn create_app_from_usage(c: &mut Criterion) {
c.bench_function("create_app_from_usage", |b| b.iter(|| 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 create_app_builder(c: &mut Criterion) {
c.bench_function("create_app_builder", |b| {
pub fn build_app_from_builder(c: &mut Criterion) {
c.bench_function("build_app_from_builder", |b| {
b.iter(|| {
App::new("claptests")
.version("0.1")
@ -162,8 +162,8 @@ pub fn create_app_builder(c: &mut Criterion) {
});
}
pub fn create_app_macros(c: &mut Criterion) {
c.bench_function("create_app_macros", |b| {
pub fn build_app_from_macros(c: &mut Criterion) {
c.bench_function("build_app_from_macros", |b| {
b.iter(|| {
clap_app!(claptests =>
(version: "0.1")
@ -198,50 +198,50 @@ pub fn create_app_macros(c: &mut Criterion) {
});
}
pub fn parse_clean(c: &mut Criterion) {
c.bench_function("parse_clean", |b| {
pub fn parse_complex_app(c: &mut Criterion) {
c.bench_function("parse_complex_app", |b| {
b.iter(|| create_app!().get_matches_from(vec![""]))
});
}
pub fn parse_flag(c: &mut Criterion) {
c.bench_function("parse_flag", |b| {
pub fn parse_complex_app_with_flag(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_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| {
pub fn parse_complex_app_with_option(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_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| {
pub fn parse_complex_app_with_positional(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_positional", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"]))
});
}
pub fn parse_sc_clean(c: &mut Criterion) {
c.bench_function("parse_sc_clean", |b| {
pub fn parse_complex_app_with_sc(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_sc", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd"]))
});
}
pub fn parse_sc_flag(c: &mut Criterion) {
c.bench_function("parse_sc_complex", |b| {
pub fn parse_complex_app_with_sc_flag(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_sc_flag", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-f"]))
});
}
pub fn parse_sc_option(c: &mut Criterion) {
c.bench_function("parse_sc_option", |b| {
pub fn parse_complex_app_with_sc_option(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_sc_option", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-o", "option1"]))
});
}
pub fn parse_sc_positional(c: &mut Criterion) {
c.bench_function("parse_sc_positional", |b| {
pub fn parse_complex_app_with_sc_positional(c: &mut Criterion) {
c.bench_function("parse_complex_app_with_sc_positional", |b| {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "arg1"]))
});
}
@ -327,17 +327,17 @@ pub fn parse_sc_complex(c: &mut Criterion) {
criterion_group!(
benches,
create_app_from_usage,
create_app_builder,
create_app_macros,
parse_clean,
parse_flag,
parse_option,
parse_positional,
parse_sc_clean,
parse_sc_flag,
parse_sc_option,
parse_sc_positional,
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,
parse_complex1,
parse_complex2,
parse_complex2_with_args_negate_scs,

View file

@ -10,32 +10,32 @@ use std::io::Cursor;
use lazy_static::lazy_static;
pub fn build_app_short(c: &mut Criterion) {
c.bench_function("build_app_short", |b| b.iter(app_short));
pub fn build_rg_with_short_help(c: &mut Criterion) {
c.bench_function("build_rg_with_short_help", |b| b.iter(app_short));
}
pub fn build_app_long(c: &mut Criterion) {
c.bench_function("build_app_long", |b| b.iter(app_long));
pub fn build_rg_with_long_help(c: &mut Criterion) {
c.bench_function("build_rg_with_long_help", |b| b.iter(app_long));
}
pub fn build_help_short(c: &mut Criterion) {
pub fn write_rg_short_help(c: &mut Criterion) {
let mut app = app_short();
c.bench_function("build_help_short", |b| b.iter(|| build_help(&mut app)));
c.bench_function("write_rg_short_help", |b| b.iter(|| build_help(&mut app)));
}
pub fn build_help_long(c: &mut Criterion) {
pub fn write_rg_long_help(c: &mut Criterion) {
let mut app = app_long();
c.bench_function("build_help_long", |b| b.iter(|| build_help(&mut app)));
c.bench_function("write_rg_long_help", |b| b.iter(|| build_help(&mut app)));
}
pub fn parse_clean(c: &mut Criterion) {
c.bench_function("parse_clean", |b| {
pub fn parse_rg(c: &mut Criterion) {
c.bench_function("parse_rg", |b| {
b.iter(|| app_short().get_matches_from(vec!["rg", "pat"]))
});
}
pub fn parse_complex(c: &mut Criterion) {
c.bench_function("parse_complex", |b| {
pub fn parse_rg_with_complex(c: &mut Criterion) {
c.bench_function("parse_rg_with_complex", |b| {
b.iter(|| {
app_short().get_matches_from(vec![
"rg",
@ -54,8 +54,8 @@ pub fn parse_complex(c: &mut Criterion) {
});
}
pub fn parse_lots(c: &mut Criterion) {
c.bench_function("parse_lots", |b| {
pub fn parse_rg_with_lots(c: &mut Criterion) {
c.bench_function("parse_rg_with_lots", |b| {
b.iter(|| {
app_short().get_matches_from(vec![
"rg", "pat", "some", "some", "some", "some", "some", "some", "some", "some",
@ -942,12 +942,12 @@ fn validate_number(s: String) -> Result<(), String> {
criterion_group!(
benches,
build_app_short,
build_app_long,
build_help_short,
build_help_long,
parse_clean,
parse_complex,
parse_lots
build_rg_with_short_help,
build_rg_with_long_help,
write_rg_short_help,
write_rg_long_help,
parse_rg,
parse_rg_with_complex,
parse_rg_with_lots
);
criterion_main!(benches);

View file

@ -5,21 +5,18 @@
use clap::{App, AppSettings, Arg, ArgGroup, ArgSettings};
use criterion::{criterion_group, criterion_main, Criterion};
criterion_group!(benches, build_app, parse_clean, parse_subcommands);
criterion_main!(benches);
pub fn build_app(c: &mut Criterion) {
c.bench_function("build_app", |b| b.iter(build_cli));
pub fn build_rustup(c: &mut Criterion) {
c.bench_function("build_rustup", |b| b.iter(build_cli));
}
pub fn parse_clean(c: &mut Criterion) {
c.bench_function("parse_clean", |b| {
pub fn parse_rustup(c: &mut Criterion) {
c.bench_function("parse_rustup", |b| {
b.iter(|| build_cli().get_matches_from(vec![""]))
});
}
pub fn parse_subcommands(c: &mut Criterion) {
c.bench_function("parse_subcommands", |b| {
pub fn parse_rustup_with_subcommands(c: &mut Criterion) {
c.bench_function("parse_rustup_with_subcommands", |b| {
b.iter(|| build_cli().get_matches_from(vec!["rustup override add stable"]))
});
}
@ -457,3 +454,12 @@ 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_main!(benches);

View file

@ -33,6 +33,7 @@ maintenance = {status = "actively-developed"}
[lib]
proc-macro = true
bench = false
[dependencies]
syn = { version = "1", features = ["full"] }

View file

@ -27,6 +27,9 @@ categories = ["command-line-interface"]
license = "MIT OR Apache-2.0"
readme = "README.md"
[lib]
bench = false
[badges]
is-it-maintained-issue-resolution = { repository = "clap-rs/clap" }
is-it-maintained-open-issues = { repository = "clap-rs/clap" }