Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Reorganise benchmarks and add noop-planning (#26)
Browse files Browse the repository at this point in the history
Change-Id: I61ff1d8ddcae2c99f74ef2ee2ba6b5da7d30c794
  • Loading branch information
Cypher1 authored Mar 10, 2022
1 parent 6a7b1e6 commit 46f223f
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 15 deletions.
6 changes: 1 addition & 5 deletions ibis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions ibis/benches/all.rs
Original file line number Diff line number Diff line change
@@ -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);
75 changes: 75 additions & 0 deletions ibis/benches/checking_and_planning.rs
Original file line number Diff line number Diff line change
@@ -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))));
}
7 changes: 2 additions & 5 deletions ibis/benches/checking_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
// 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) {
let _result = best_solutions_to_json(&data);
// 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": {
Expand Down Expand Up @@ -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);
7 changes: 2 additions & 5 deletions ibis/benches/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
// 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) {
let _result = best_solutions_to_json(&data);
// 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);

0 comments on commit 46f223f

Please sign in to comment.