Skip to content

Commit

Permalink
Add bustle benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Feb 26, 2020
1 parent d72da26 commit 3fc4f9d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ default-features = false
rand = "0.7"
rayon = "1.3"
criterion = "0.3"
bustle = "0.1"

[profile.bench]
debug = true

[[bench]]
name = "flurry_dashmap"
Expand All @@ -43,3 +47,7 @@ harness = false
[[bench]]
name = "flurry_hashbrown"
harness = false

[[bench]]
name = "bustle"
harness = false
40 changes: 40 additions & 0 deletions benches/bustle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use bustle::*;
use flurry::*;
use std::sync::Arc;

#[derive(Clone)]
struct Table<K: 'static + Send + Sync>(Arc<HashMap<K, ()>>);

impl<K> BenchmarkTarget for Table<K>
where
K: Sync + Send + From<u64> + Copy + 'static + std::hash::Hash + Eq + std::fmt::Debug,
{
type Key = K;

fn with_capacity(capacity: usize) -> Self {
Self(Arc::new(HashMap::with_capacity(capacity)))
}

fn get(&mut self, key: &Self::Key) -> bool {
self.0.pin().get(key).is_some()
}

fn insert(&mut self, key: &Self::Key) -> bool {
self.0.pin().insert(*key, ()).is_some()
}

fn remove(&mut self, key: &Self::Key) -> bool {
self.0.pin().remove(key).is_some()
}

fn update(&mut self, key: &Self::Key) -> bool {
self.0
.pin()
.compute_if_present(key, |_, _| Some(()))
.is_some()
}
}

fn main() {
Workload::new(1, Mix::read_heavy()).run::<Table<u64>>();
}

0 comments on commit 3fc4f9d

Please sign in to comment.