cht bench

This commit is contained in:
Acrimon 2019-11-19 18:40:42 +01:00
parent ed79f53995
commit 4462a82cb8
No known key found for this signature in database
GPG Key ID: 5F96EDD054C9729E
2 changed files with 36 additions and 0 deletions

View File

@ -20,6 +20,7 @@ criterion = "0.3"
rayon = "1.2.0"
chashmap = "2.2.2"
contrie = "0.1.4"
cht = "0.1.2"
[[bench]]
name = "rwlock_std"
@ -37,6 +38,10 @@ harness = false
name = "contrie"
harness = false
[[bench]]
name = "cht"
harness = false
[dependencies]
dashmap-shard = { version = "0.1.1", default-features = false }
parking_lot = "0.9.0"

31
benches/cht.rs Normal file
View File

@ -0,0 +1,31 @@
use criterion::{criterion_group, criterion_main, Criterion, BenchmarkId, Throughput};
use rayon::prelude::*;
use cht::HashMap;
const ITER: u64 = 8 * 1024;
fn task_insert_cht_u64_u64() -> HashMap<u64, u64> {
let map = HashMap::new();
(0..ITER).into_par_iter().for_each(|i| {
map.insert(i, i + 7);
});
map
}
fn insert_cht_u64_u64(c: &mut Criterion) {
let mut group = c.benchmark_group("insert_cht_u64_u64");
group.throughput(Throughput::Elements(ITER as u64));
let max = num_cpus::get();
for threads in 1..=max {
group.bench_with_input(BenchmarkId::from_parameter(threads), &threads, |b, &threads| {
let pool = rayon::ThreadPoolBuilder::new().num_threads(threads).build().unwrap();
pool.install(|| b.iter(|| task_insert_cht_u64_u64()));
});
}
group.finish();
}
criterion_group!(benches, insert_cht_u64_u64);
criterion_main!(benches);