From 3fc4f9d6c83ac91d5a2c2b2877c001ea85d36a7a Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 26 Feb 2020 16:07:35 -0500 Subject: [PATCH] Add bustle benchmark --- Cargo.toml | 8 ++++++++ benches/bustle.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 benches/bustle.rs diff --git a/Cargo.toml b/Cargo.toml index 7448291b..e79dfbc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -43,3 +47,7 @@ harness = false [[bench]] name = "flurry_hashbrown" harness = false + +[[bench]] +name = "bustle" +harness = false diff --git a/benches/bustle.rs b/benches/bustle.rs new file mode 100644 index 00000000..0fdafce2 --- /dev/null +++ b/benches/bustle.rs @@ -0,0 +1,40 @@ +use bustle::*; +use flurry::*; +use std::sync::Arc; + +#[derive(Clone)] +struct Table(Arc>); + +impl BenchmarkTarget for Table +where + K: Sync + Send + From + 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::>(); +}