-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,7 @@ criterion = "0.3" | |
[[bench]] | ||
name = "merk" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "ops" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,84 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
||
use criterion::*; | ||
use merk::owner::Owner; | ||
use merk::test_utils::*; | ||
use test::Bencher; | ||
|
||
#[bench] | ||
fn insert_1m_10k_seq_memonly(b: &mut Bencher) { | ||
fn insert_1m_10k_seq_memonly(c: &mut Criterion) { | ||
let initial_size = 1_000_000; | ||
let batch_size = 10_000; | ||
|
||
let mut tree = Owner::new(make_tree_seq(initial_size)); | ||
|
||
let mut i = initial_size / batch_size; | ||
b.iter(|| { | ||
let batch = make_batch_seq((i * batch_size)..((i + 1) * batch_size)); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i += 1; | ||
}); | ||
c.bench_function( | ||
"insert_1m_10k_seq_memonly", | ||
|b| b.iter(|| { | ||
let batch = make_batch_seq((i * batch_size)..((i + 1) * batch_size)); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i += 1; | ||
}) | ||
); | ||
} | ||
|
||
#[bench] | ||
fn insert_1m_10k_rand_memonly(b: &mut Bencher) { | ||
fn insert_1m_10k_rand_memonly(c: &mut Criterion) { | ||
let initial_size = 1_000_000; | ||
let batch_size = 10_000; | ||
|
||
let mut tree = Owner::new(make_tree_rand(initial_size, batch_size, 0)); | ||
|
||
let mut i = initial_size / batch_size; | ||
b.iter(|| { | ||
let batch = make_batch_rand(batch_size, i); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i += 1; | ||
}); | ||
c.bench_function( | ||
"insert_1m_10k_rand_memonly", | ||
|b| b.iter(|| { | ||
let batch = make_batch_rand(batch_size, i); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i += 1; | ||
}) | ||
); | ||
} | ||
|
||
#[bench] | ||
fn update_1m_10k_seq_memonly(b: &mut Bencher) { | ||
fn update_1m_10k_seq_memonly(c: &mut Criterion) { | ||
let initial_size = 1_000_000; | ||
let batch_size = 10_000; | ||
|
||
let mut tree = Owner::new(make_tree_seq(initial_size)); | ||
|
||
let mut i = 0; | ||
b.iter(|| { | ||
let batch = make_batch_seq((i * batch_size)..((i + 1) * batch_size)); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i = (i + 1) % (initial_size / batch_size); | ||
}); | ||
c.bench_function( | ||
"update_1m_10k_seq_memonly", | ||
|b| b.iter(|| { | ||
let batch = make_batch_seq((i * batch_size)..((i + 1) * batch_size)); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i = (i + 1) % (initial_size / batch_size); | ||
}) | ||
); | ||
} | ||
|
||
#[bench] | ||
fn update_1m_10k_rand_memonly(b: &mut Bencher) { | ||
fn update_1m_10k_rand_memonly(c: &mut Criterion) { | ||
let initial_size = 1_010_000; | ||
let batch_size = 10_000; | ||
|
||
let mut tree = Owner::new(make_tree_rand(initial_size, batch_size, 0)); | ||
|
||
let mut i = 0; | ||
b.iter(|| { | ||
let batch = make_batch_rand(batch_size, i); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i = (i + 1) % (initial_size / batch_size); | ||
}); | ||
c.bench_function( | ||
"update_1m_10k_rand_memonly", | ||
|b| b.iter(|| { | ||
let batch = make_batch_rand(batch_size, i); | ||
tree.own(|tree| apply_memonly_unchecked(tree, &batch)); | ||
i = (i + 1) % (initial_size / batch_size); | ||
}) | ||
); | ||
} | ||
|
||
criterion_group!{ | ||
name = ops; | ||
config = Criterion::default(); | ||
targets = insert_1m_10k_seq_memonly, | ||
insert_1m_10k_rand_memonly, | ||
update_1m_10k_seq_memonly, | ||
update_1m_10k_rand_memonly, | ||
} | ||
|
||
criterion_main!(ops); |