chore: Unify benchmark names

Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
This commit is contained in:
Dmitry Dygalo 2021-10-21 09:43:21 +02:00 committed by Dmitry Dygalo
parent 625c66ee25
commit b57debf7fc
4 changed files with 21 additions and 21 deletions

View File

@ -85,7 +85,7 @@ pub fn bench_keywords(
let suffix = strip_characters(&instance.to_string());
bench_valid(
c,
&format!("{} valid {}", benchmark.name, suffix),
&format!("{} {}", benchmark.name, suffix),
&benchmark.schema,
&instance,
)
@ -99,7 +99,7 @@ pub fn bench_keywords(
let suffix = strip_characters(&instance.to_string());
bench_invalid(
c,
&format!("{} invalid {}", benchmark.name, suffix),
&format!("{} {}", benchmark.name, suffix),
&benchmark.schema,
&instance,
)

View File

@ -13,13 +13,13 @@ macro_rules! jsonschema_rs_bench {
.expect("Invalid schema");
assert!(compiled.is_valid(&$instance), "Invalid instance");
assert!(compiled.validate(&$instance).is_ok(), "Invalid instance");
$c.bench_function(&format!("jsonschema-rs {} compile", $name), |b| {
$c.bench_function(&format!("{} jsonschema_rs/compile", $name), |b| {
b.iter(|| JSONSchema::options().with_meta_schemas().compile(&$schema))
});
$c.bench_function(&format!("jsonschema-rs {} is_valid", $name), |b| {
$c.bench_function(&format!("{} jsonschema_rs/is_valid", $name), |b| {
b.iter(|| compiled.is_valid(&$instance))
});
$c.bench_function(&format!("jsonschema-rs {} validate", $name), |b| {
$c.bench_function(&format!("{} jsonschema_rs/validate", $name), |b| {
b.iter(|| compiled.validate(&$instance).ok())
});
}};
@ -42,19 +42,19 @@ fn fast_schema(c: &mut Criterion) {
let compiled = JSONSchema::compile(&schema).expect("Valid schema");
assert!(compiled.is_valid(&valid));
assert!(!compiled.is_valid(&invalid));
c.bench_function(&format!("jsonschema-rs {} compile", name), |b| {
c.bench_function(&format!("{} jsonschema_rs/compile", name), |b| {
b.iter(|| JSONSchema::compile(&schema).expect("Valid schema"))
});
c.bench_function(&format!("jsonschema-rs {} is_valid valid", name), |b| {
c.bench_function(&format!("{} jsonschema_rs/is_valid/valid", name), |b| {
b.iter(|| compiled.is_valid(&valid))
});
c.bench_function(&format!("jsonschema-rs {} validate valid", name), |b| {
c.bench_function(&format!("{} jsonschema_rs/validate/valid", name), |b| {
b.iter(|| compiled.validate(&valid).ok())
});
c.bench_function(&format!("jsonschema-rs {} is_valid invalid", name), |b| {
c.bench_function(&format!("{} jsonschema_rs/is_valid/invalid", name), |b| {
b.iter(|| compiled.is_valid(&invalid))
});
c.bench_function(&format!("jsonschema-rs {} validate invalid", name), |b| {
c.bench_function(&format!("{} jsonschema_rs/validate/invalid", name), |b| {
b.iter(|| {
let _: Vec<_> = compiled
.validate(&invalid)
@ -92,7 +92,7 @@ fn keywords(c: &mut Criterion) {
fn validate_valid(c: &mut Criterion, name: &str, schema: &Value, instance: &Value) {
let compiled = JSONSchema::compile(schema).expect("Valid schema");
c.bench_with_input(
BenchmarkId::new(name, "jsonschema_rs/is_valid"),
BenchmarkId::new(name, "jsonschema_rs/is_valid/valid"),
instance,
|b, instance| {
b.iter(|| {
@ -101,7 +101,7 @@ fn validate_valid(c: &mut Criterion, name: &str, schema: &Value, instance: &Valu
},
);
c.bench_with_input(
BenchmarkId::new(name, "jsonschema_rs/validate"),
BenchmarkId::new(name, "jsonschema_rs/validate/valid"),
instance,
|b, instance| {
b.iter(|| {
@ -114,7 +114,7 @@ fn validate_valid(c: &mut Criterion, name: &str, schema: &Value, instance: &Valu
fn validate_invalid(c: &mut Criterion, name: &str, schema: &Value, instance: &Value) {
let compiled = JSONSchema::compile(schema).expect("Valid schema");
c.bench_with_input(
BenchmarkId::new(name, "jsonschema_rs/is_valid"),
BenchmarkId::new(name, "jsonschema_rs/is_valid/invalid"),
instance,
|b, instance| {
b.iter(|| {
@ -123,7 +123,7 @@ fn validate_invalid(c: &mut Criterion, name: &str, schema: &Value, instance: &Va
},
);
c.bench_with_input(
BenchmarkId::new(name, "jsonschema_rs/validate"),
BenchmarkId::new(name, "jsonschema_rs/validate/invalid"),
instance,
|b, instance| {
b.iter(|| {

View File

@ -11,7 +11,7 @@ macro_rules! jsonschema_valid_bench {
jsonschema_valid::validate(&cfg, &$instance).is_ok(),
"Invalid instance"
);
$c.bench_function(&format!("jsonschema-valid {}", $name), |b| {
$c.bench_function(&format!("{} jsonschema_valid/validate/valid", $name), |b| {
// There is no specialized method for fast boolean return value
b.iter(|| jsonschema_valid::validate(&cfg, &$instance).is_ok())
});
@ -33,17 +33,17 @@ fn fast_schema(c: &mut Criterion) {
bench_fast(&mut |name, schema, valid, invalid| {
let cfg = jsonschema_valid::Config::from_schema(&schema, Some(schemas::Draft::Draft7))
.expect("Valid schema");
c.bench_function(&format!("jsonschema_valid {} compile", name), |b| {
c.bench_function(&format!("{} jsonschema_valid/compile", name), |b| {
b.iter(|| {
jsonschema_valid::Config::from_schema(&schema, Some(schemas::Draft::Draft7))
.expect("Valid schema")
})
});
c.bench_function(&format!("jsonschema_valid {} validate valid", name), |b| {
c.bench_function(&format!("{} jsonschema_valid/validate/valid", name), |b| {
b.iter(|| jsonschema_valid::validate(&cfg, &valid))
});
c.bench_function(
&format!("jsonschema_valid {} validate invalid", name),
&format!("{} jsonschema_valid/validate/invalid", name),
|b| b.iter(|| jsonschema_valid::validate(&cfg, &invalid).ok()),
);
});

View File

@ -32,7 +32,7 @@ fn fast_schema(c: &mut Criterion) {
let compiled = scope
.compile_and_return(schema.clone(), false)
.expect("Valid schema");
c.bench_function(&format!("valico {} compile", name), |b| {
c.bench_function(&format!("{} valico/compile", name), |b| {
b.iter(|| {
let mut scope = json_schema::Scope::new();
scope
@ -40,10 +40,10 @@ fn fast_schema(c: &mut Criterion) {
.expect("Valid schema");
})
});
c.bench_function(&format!("valico {} validate valid", name), |b| {
c.bench_function(&format!("{} valico/validate/valid", name), |b| {
b.iter(|| compiled.validate(&valid).is_valid())
});
c.bench_function(&format!("valico {} validate invalid", name), |b| {
c.bench_function(&format!("{} valico/validate/invalid", name), |b| {
b.iter(|| compiled.validate(&invalid).is_valid())
});
});