Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarks using triomphe::Arc #85

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ include = [
codecov = { repository = "orium/rpds", branch = "master", service = "github" }

[dependencies]
archery = "1.0.0"
# FIXME: use release
# archery = "1.0.0"
archery = { git = "https://github.com/michaelsproul/archery", branch = "triomphe" }
serde = { version = "1.0.149", optional = true, default-features = false }

[dev-dependencies]
Expand All @@ -54,6 +56,7 @@ static_assertions = "1.1.0"
default = ["std"]
fatal-warnings = []
std = []
triomphe-bench = ["archery/triomphe"]

[package.metadata.docs.rs]
features = ["serde"]
Expand Down
18 changes: 11 additions & 7 deletions benches/rpds_hash_trie_map_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

use criterion::{criterion_group, criterion_main, Criterion};
use rpds::HashTrieMapSync;
use std::hint::black_box;

#[cfg(not(feature = "triomphe-bench"))]
type HashTrieMapSync<K, V> = rpds::HashTrieMapSync<K, V>;
#[cfg(feature = "triomphe-bench")]
type HashTrieMapSync<K, V> = rpds::HashTrieMap<K, V, archery::ArcTK>;

fn rpds_hash_trie_map_sync_insert(c: &mut Criterion) {
let limit = 10_000;

c.bench_function("rpds hash trie map sync insert", move |b| {
b.iter(|| {
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map = map.insert(i, -(i as isize));
Expand All @@ -30,7 +34,7 @@ fn rpds_hash_trie_map_sync_insert_mut(c: &mut Criterion) {

c.bench_function("rpds hash trie map sync insert mut", move |b| {
b.iter(|| {
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -47,7 +51,7 @@ fn rpds_hash_trie_map_sync_remove(c: &mut Criterion) {
c.bench_function("rpds hash trie map sync remove", move |b| {
b.iter_with_setup(
|| {
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -72,7 +76,7 @@ fn rpds_hash_trie_map_sync_remove_mut(c: &mut Criterion) {
c.bench_function("rpds hash trie map sync remove mut", move |b| {
b.iter_with_setup(
|| {
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -93,7 +97,7 @@ fn rpds_hash_trie_map_sync_remove_mut(c: &mut Criterion) {

fn rpds_hash_trie_map_sync_get(c: &mut Criterion) {
let limit = 10_000;
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -110,7 +114,7 @@ fn rpds_hash_trie_map_sync_get(c: &mut Criterion) {

fn rpds_hash_trie_map_sync_iterate(c: &mut Criterion) {
let limit = 10_000;
let mut map = HashTrieMapSync::new_sync();
let mut map = HashTrieMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand Down
20 changes: 12 additions & 8 deletions benches/rpds_list_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

use criterion::{criterion_group, criterion_main, Criterion};
use rpds::ListSync;
use std::hint::black_box;

#[cfg(not(feature = "triomphe-bench"))]
use rpds::ListSync;
#[cfg(feature = "triomphe-bench")]
type ListSync<T> = rpds::List<T, archery::ArcTK>;

fn rpds_list_sync_push_front(c: &mut Criterion) {
let limit = 10_000;

c.bench_function("rpds list sync push front", move |b| {
b.iter(|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list = list.push_front(i);
Expand All @@ -30,7 +34,7 @@ fn rpds_list_sync_push_front_mut(c: &mut Criterion) {

c.bench_function("rpds list sync push front mut", move |b| {
b.iter(|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand All @@ -47,7 +51,7 @@ fn rpds_list_sync_drop_first(c: &mut Criterion) {
c.bench_function("rpds list sync drop first", move |b| {
b.iter_with_setup(
|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand All @@ -72,7 +76,7 @@ fn rpds_list_sync_drop_first_mut(c: &mut Criterion) {
c.bench_function("rpds list sync drop first mut", move |b| {
b.iter_with_setup(
|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand All @@ -97,7 +101,7 @@ fn rpds_list_sync_reverse(c: &mut Criterion) {
c.bench_function("rpds list sync reverse", move |b| {
b.iter_with_setup(
|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand All @@ -122,7 +126,7 @@ fn rpds_list_sync_reverse_mut(c: &mut Criterion) {
c.bench_function("rpds list sync reverse mut", move |b| {
b.iter_with_setup(
|| {
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand All @@ -143,7 +147,7 @@ fn rpds_list_sync_reverse_mut(c: &mut Criterion) {

fn rpds_list_sync_iterate(c: &mut Criterion) {
let limit = 10_000;
let mut list: ListSync<usize> = ListSync::new_sync();
let mut list: ListSync<usize> = ListSync::new_with_ptr_kind();

for i in 0..limit {
list.push_front_mut(i);
Expand Down
16 changes: 10 additions & 6 deletions benches/rpds_queue_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

use criterion::{criterion_group, criterion_main, Criterion};
use rpds::QueueSync;
use std::hint::black_box;

#[cfg(not(feature = "triomphe-bench"))]
use rpds::QueueSync;
#[cfg(feature = "triomphe-bench")]
type QueueSync<T> = rpds::Queue<T, archery::ArcTK>;

fn rpds_queue_sync_enqueue(c: &mut Criterion) {
let limit = 10_000;

c.bench_function("rpds queue sync enqueue", move |b| {
b.iter(|| {
let mut queue: QueueSync<usize> = QueueSync::new_sync();
let mut queue: QueueSync<usize> = QueueSync::new_with_ptr_kind();

for i in 0..limit {
queue = queue.enqueue(i);
Expand All @@ -30,7 +34,7 @@ fn rpds_queue_sync_enqueue_mut(c: &mut Criterion) {

c.bench_function("rpds queue sync enqueue mut", move |b| {
b.iter(|| {
let mut queue: QueueSync<usize> = QueueSync::new_sync();
let mut queue: QueueSync<usize> = QueueSync::new_with_ptr_kind();

for i in 0..limit {
queue.enqueue_mut(i);
Expand All @@ -47,7 +51,7 @@ fn rpds_queue_sync_dequeue(c: &mut Criterion) {
c.bench_function("rpds queue sync dequeue", move |b| {
b.iter_with_setup(
|| {
let mut queue: QueueSync<usize> = QueueSync::new_sync();
let mut queue: QueueSync<usize> = QueueSync::new_with_ptr_kind();

for i in 0..limit {
queue.enqueue_mut(i);
Expand All @@ -72,7 +76,7 @@ fn rpds_queue_sync_dequeue_mut(c: &mut Criterion) {
c.bench_function("rpds queue sync dequeue mut", move |b| {
b.iter_with_setup(
|| {
let mut queue: QueueSync<usize> = QueueSync::new_sync();
let mut queue: QueueSync<usize> = QueueSync::new_with_ptr_kind();

for i in 0..limit {
queue.enqueue_mut(i);
Expand All @@ -93,7 +97,7 @@ fn rpds_queue_sync_dequeue_mut(c: &mut Criterion) {

fn rpds_queue_sync_iterate(c: &mut Criterion) {
let limit = 10_000;
let mut queue: QueueSync<usize> = QueueSync::new_sync();
let mut queue: QueueSync<usize> = QueueSync::new_with_ptr_kind();

for i in 0..limit {
queue.enqueue_mut(i);
Expand Down
18 changes: 11 additions & 7 deletions benches/rpds_red_black_tree_map_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

use criterion::{criterion_group, criterion_main, Criterion};
use rpds::RedBlackTreeMapSync;
use std::hint::black_box;

#[cfg(not(feature = "triomphe-bench"))]
use rpds::RedBlackTreeMapSync;
#[cfg(feature = "triomphe-bench")]
type RedBlackTreeMapSync<K, V> = rpds::RedBlackTreeMap<K, V, archery::ArcTK>;

fn rpds_red_black_tree_map_sync_insert(c: &mut Criterion) {
let limit = 10_000;

c.bench_function("rpds red black tree map sync insert", move |b| {
b.iter(|| {
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map = map.insert(i, -(i as isize));
Expand All @@ -30,7 +34,7 @@ fn rpds_red_black_tree_map_sync_insert_mut(c: &mut Criterion) {

c.bench_function("rpds red black tree map sync insert mut", move |b| {
b.iter(|| {
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -47,7 +51,7 @@ fn rpds_red_black_tree_map_sync_remove(c: &mut Criterion) {
c.bench_function("rpds red black tree map sync remove", move |b| {
b.iter_with_setup(
|| {
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -72,7 +76,7 @@ fn rpds_red_black_tree_map_sync_remove_mut(c: &mut Criterion) {
c.bench_function("rpds red black tree map sync remove mut", move |b| {
b.iter_with_setup(
|| {
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -93,7 +97,7 @@ fn rpds_red_black_tree_map_sync_remove_mut(c: &mut Criterion) {

fn rpds_red_black_tree_map_sync_get(c: &mut Criterion) {
let limit = 10_000;
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand All @@ -110,7 +114,7 @@ fn rpds_red_black_tree_map_sync_get(c: &mut Criterion) {

fn rpds_red_black_tree_map_sync_iterate(c: &mut Criterion) {
let limit = 10_000;
let mut map = RedBlackTreeMapSync::new_sync();
let mut map = RedBlackTreeMapSync::default();

for i in 0..limit {
map.insert_mut(i, -(i as isize));
Expand Down
18 changes: 11 additions & 7 deletions benches/rpds_vector_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

use criterion::{criterion_group, criterion_main, Criterion};
use rpds::VectorSync;
use std::hint::black_box;

#[cfg(not(feature = "triomphe-bench"))]
use rpds::VectorSync;
#[cfg(feature = "triomphe-bench")]
type VectorSync<T> = rpds::Vector<T, archery::ArcTK>;

fn rpds_vector_syncpush_back(c: &mut Criterion) {
let limit = 10_000;

c.bench_function("rpds vector sync push back", move |b| {
b.iter(|| {
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector = vector.push_back(i);
Expand All @@ -30,7 +34,7 @@ fn rpds_vector_syncpush_back_mut(c: &mut Criterion) {

c.bench_function("rpds vector sync push back mut", move |b| {
b.iter(|| {
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector.push_back_mut(i);
Expand All @@ -47,7 +51,7 @@ fn rpds_vector_syncdrop_last(c: &mut Criterion) {
c.bench_function("rpds vector sync drop last", move |b| {
b.iter_with_setup(
|| {
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector.push_back_mut(i);
Expand All @@ -72,7 +76,7 @@ fn rpds_vector_syncdrop_last_mut(c: &mut Criterion) {
c.bench_function("rpds vector sync drop last mut", move |b| {
b.iter_with_setup(
|| {
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector.push_back_mut(i);
Expand All @@ -93,7 +97,7 @@ fn rpds_vector_syncdrop_last_mut(c: &mut Criterion) {

fn rpds_vector_syncget(c: &mut Criterion) {
let limit = 10_000;
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector.push_back_mut(i);
Expand All @@ -110,7 +114,7 @@ fn rpds_vector_syncget(c: &mut Criterion) {

fn rpds_vector_synciterate(c: &mut Criterion) {
let limit = 10_000;
let mut vector: VectorSync<usize> = VectorSync::new_sync();
let mut vector: VectorSync<usize> = VectorSync::new_with_ptr_kind();

for i in 0..limit {
vector.push_back_mut(i);
Expand Down
Loading