From 46f223fd23b1406237424128a456f98555252ce3 Mon Sep 17 00:00:00 2001 From: J Pratt Date: Thu, 10 Mar 2022 15:49:56 +1100 Subject: [PATCH] Reorganise benchmarks and add noop-planning (#26) Change-Id: I61ff1d8ddcae2c99f74ef2ee2ba6b5da7d30c794 --- ibis/Cargo.toml | 6 +-- ibis/benches/all.rs | 23 ++++++++ ibis/benches/checking_and_planning.rs | 75 +++++++++++++++++++++++++++ ibis/benches/checking_only.rs | 7 +-- ibis/benches/demo.rs | 7 +-- 5 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 ibis/benches/all.rs create mode 100644 ibis/benches/checking_and_planning.rs diff --git a/ibis/Cargo.toml b/ibis/Cargo.toml index be0fbb205..bd3d564bf 100644 --- a/ibis/Cargo.toml +++ b/ibis/Cargo.toml @@ -48,9 +48,5 @@ debug = true wasm-opt = ["-O4", "--enable-mutable-globals"] [[bench]] -name = "demo" -harness = false - -[[bench]] -name = "checking_only" +name = "all" harness = false diff --git a/ibis/benches/all.rs b/ibis/benches/all.rs new file mode 100644 index 000000000..f919af6b5 --- /dev/null +++ b/ibis/benches/all.rs @@ -0,0 +1,23 @@ +// Copyright 2022 Google LLC +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +use criterion::{criterion_group, criterion_main}; + +mod checking_and_planning; +mod checking_only; +mod demo; + +use checking_and_planning::*; +use checking_only::*; +use demo::*; + +criterion_group!( + benches, + criterion_benchmark_checking_only, + criterion_benchmark_noop_planning, + criterion_benchmark_solve_demo +); +criterion_main!(benches); diff --git a/ibis/benches/checking_and_planning.rs b/ibis/benches/checking_and_planning.rs new file mode 100644 index 000000000..56c939d29 --- /dev/null +++ b/ibis/benches/checking_and_planning.rs @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +use criterion::{black_box, Criterion}; +use ibis::best_solutions_to_json; + +fn solve_demo(data: &str) { + let _result = best_solutions_to_json(&data); + // TODO: use the result to ensure it is correct +} + +pub fn criterion_benchmark_noop_planning(c: &mut Criterion) { + let data = r#" +{ + "flags": { + "planning": true + }, + "capabilities": [ + ["write", "read"], + ["any", "read"], + ["write", "any"] + ], + "subtypes": [ + ["Int", "Number"], + ["Int", "Serializable"], + ["String", "Serializable"] + ], + "less_private_than": [ + ["public", "private"] + ], + "recipes": [ + { + "nodes": [ + ["p_a", "a", "write", "Int"], + ["p_b", "b", "any", "Number"], + ["p_c", "c", "write", "String"], + ["p_de", "d", "read", "Serializable"], + ["p_de", "e", "read", "ibis.UnionType(Number, String)"], + ["p_f", "f", "write", "ibis.ProductType(name: String, age: Int)"], + ["p_g", "g", "read", "name: *"], + ["p_h", "h", "read", "ibis.ProductType(name: String, age: Int)"], + ["p_i", "i", "read", "name: String"], + ["p_j", "j", "read", "age: Int"] + ], + "claims": [ + ["a", "private"] + ], + "checks": [ + ["e", "public"] + ], + "trusted_to_remove_tag": [ + ["b", "private"] + ], + "edges": [ + ["a", "b"], + ["b", "e"], + ["c", "d"], + ["c", "e"], + ["f", "b"], + ["f", "d"], + ["f", "e"], + ["f", "g"], + ["f", "h"], + ["f", "i"], + ["f", "j"] + ] + } + ] +} +"#; + c.bench_function("noop_planning", |b| b.iter(|| solve_demo(black_box(data)))); +} diff --git a/ibis/benches/checking_only.rs b/ibis/benches/checking_only.rs index 55f1360e1..615a83ab5 100644 --- a/ibis/benches/checking_only.rs +++ b/ibis/benches/checking_only.rs @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{black_box, Criterion}; use ibis::best_solutions_to_json; fn solve_demo(data: &str) { @@ -12,7 +12,7 @@ fn solve_demo(data: &str) { // TODO: use the result to ensure it is correct } -fn criterion_benchmark_solve_demo(c: &mut Criterion) { +pub fn criterion_benchmark_checking_only(c: &mut Criterion) { let data = r#" { "flags": { @@ -73,6 +73,3 @@ fn criterion_benchmark_solve_demo(c: &mut Criterion) { "#; c.bench_function("checking_only", |b| b.iter(|| solve_demo(black_box(data)))); } - -criterion_group!(benches, criterion_benchmark_solve_demo); -criterion_main!(benches); diff --git a/ibis/benches/demo.rs b/ibis/benches/demo.rs index 2556f7570..b05ad5ad5 100644 --- a/ibis/benches/demo.rs +++ b/ibis/benches/demo.rs @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{black_box, Criterion}; use ibis::best_solutions_to_json; fn solve_demo(data: &str) { @@ -12,12 +12,9 @@ fn solve_demo(data: &str) { // TODO: use the result to ensure it is correct } -fn criterion_benchmark_solve_demo(c: &mut Criterion) { +pub fn criterion_benchmark_solve_demo(c: &mut Criterion) { let data = include_str!("../demo.json"); c.bench_function("solve demo.json", |b| { b.iter(|| solve_demo(black_box(data))) }); } - -criterion_group!(benches, criterion_benchmark_solve_demo); -criterion_main!(benches);