From b57debf7fc502080638f3e1c8e9780e76c8d4619 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Thu, 21 Oct 2021 09:43:21 +0200 Subject: [PATCH] chore: Unify benchmark names Signed-off-by: Dmitry Dygalo --- bench_helpers/src/lib.rs | 4 ++-- jsonschema/benches/jsonschema.rs | 24 ++++++++++++------------ jsonschema/benches/jsonschema_valid.rs | 8 ++++---- jsonschema/benches/valico.rs | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bench_helpers/src/lib.rs b/bench_helpers/src/lib.rs index 203d8d3..122c6ce 100644 --- a/bench_helpers/src/lib.rs +++ b/bench_helpers/src/lib.rs @@ -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, ) diff --git a/jsonschema/benches/jsonschema.rs b/jsonschema/benches/jsonschema.rs index 8bb24ac..a92d054 100644 --- a/jsonschema/benches/jsonschema.rs +++ b/jsonschema/benches/jsonschema.rs @@ -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(|| { diff --git a/jsonschema/benches/jsonschema_valid.rs b/jsonschema/benches/jsonschema_valid.rs index a7d3c51..3511c24 100644 --- a/jsonschema/benches/jsonschema_valid.rs +++ b/jsonschema/benches/jsonschema_valid.rs @@ -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()), ); }); diff --git a/jsonschema/benches/valico.rs b/jsonschema/benches/valico.rs index 9af8344..24fdaa1 100644 --- a/jsonschema/benches/valico.rs +++ b/jsonschema/benches/valico.rs @@ -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()) }); });