Skip to content
Snippets Groups Projects
Verified Commit de7a47c1 authored by David Mehren's avatar David Mehren
Browse files

Update benchmarks to use big trees

parent 1658d633
Branches
No related tags found
No related merge requests found
#[macro_use]
extern crate criterion;
extern crate bv;
extern crate fp_succinct_trees_1;
extern crate id_tree;
use criterion::Criterion;
use criterion::Fun;
use fp_succinct_trees_1::bp_tree::BPTree;
use fp_succinct_trees_1::common::succinct_tree::SuccinctTree;
use fp_succinct_trees_1::trees::bp_tree::BPTree;
use fp_succinct_trees_1::trees::louds_tree::LOUDSTree;
use fp_succinct_trees_1::louds_tree::LOUDSTree;
use id_tree::InsertBehavior::*;
use id_tree::Node;
use id_tree::NodeId;
......@@ -34,6 +35,22 @@ fn create_bench_tree() -> Tree<i32> {
tree
}
fn create_bench_louds() -> LOUDSTree<i32> {
LOUDSTree::from_file("testdata/loudshuge.benchdata".to_string()).unwrap()
}
fn create_bench_bp() -> BPTree<i32> {
BPTree::from_file("testdata/bphuge.benchdata".to_string()).unwrap()
}
fn compare_load_huge_tree(c: &mut Criterion) {
let louds = Fun::new("LOUDS from file", |b, i| b.iter(|| create_bench_louds()));
let bp = Fun::new("BP from file", |b, i| {
b.iter(|| create_bench_bp());
});
c.bench_functions("Load huge trees", vec![louds, bp], 0);
}
fn create_bench_idtree(c: &mut Criterion) {
let tree = create_bench_tree();
c.bench_function("Create bench tree", |b| b.iter(|| create_bench_tree()));
......@@ -50,32 +67,32 @@ fn compare_from_id_tree(c: &mut Criterion) {
}
fn compare_is_leaf(c: &mut Criterion) {
let louds = LOUDSTree::from_id_tree(create_bench_tree()).unwrap();
let bp = BPTree::from_id_tree(create_bench_tree()).unwrap();
let louds = create_bench_louds();
let bp = create_bench_bp();
let louds_fun = Fun::new("LOUDS", move |b, _| b.iter(|| louds.is_leaf(1)));
let bp_fun = Fun::new("BP", move |b, _| b.iter(|| bp.is_leaf(1)));
c.bench_functions("Compare is_leaf()", vec![louds_fun, bp_fun], 0);
}
fn compare_parent(c: &mut Criterion) {
let louds = LOUDSTree::from_id_tree(create_bench_tree()).unwrap();
let bp = BPTree::from_id_tree(create_bench_tree()).unwrap();
let louds = create_bench_louds();
let bp = create_bench_bp();
let louds_fun = Fun::new("LOUDS", move |b, _| b.iter(|| louds.parent(1)));
let bp_fun = Fun::new("BP", move |b, _| b.iter(|| bp.parent(1)));
c.bench_functions("Compare parent()", vec![louds_fun, bp_fun], 0);
}
fn compare_first_child(c: &mut Criterion) {
let louds = LOUDSTree::from_id_tree(create_bench_tree()).unwrap();
let bp = BPTree::from_id_tree(create_bench_tree()).unwrap();
let louds = create_bench_louds();
let bp = create_bench_bp();
let louds_fun = Fun::new("LOUDS", move |b, _| b.iter(|| louds.first_child(1)));
let bp_fun = Fun::new("BP", move |b, _| b.iter(|| bp.first_child(1)));
c.bench_functions("Compare first_child()", vec![louds_fun, bp_fun], 0);
}
fn compare_next_sibling(c: &mut Criterion) {
let louds = LOUDSTree::from_id_tree(create_bench_tree()).unwrap();
let bp = BPTree::from_id_tree(create_bench_tree()).unwrap();
let louds = create_bench_louds();
let bp = create_bench_bp();
let louds_fun = Fun::new("LOUDS", move |b, _| b.iter(|| louds.next_sibling(1)));
let bp_fun = Fun::new("BP", move |b, _| b.iter(|| bp.next_sibling(1)));
c.bench_functions("Compare next_sibling()", vec![louds_fun, bp_fun], 0);
......@@ -84,6 +101,8 @@ fn compare_next_sibling(c: &mut Criterion) {
criterion_group!(
benches,
create_bench_idtree,
compare_load_huge_tree,
compare_parent,
compare_from_id_tree,
compare_is_leaf,
compare_first_child,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment