diff --git a/Cargo.toml b/Cargo.toml index 71572f7..816b8f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ codecov = { repository = "orium/rpds", branch = "master", service = "github" } [dependencies] # FIXME: use release # archery = "1.0.0" -archery = { git = "https://github.com/michaelsproul/archery", branch = "triomphe", features = ["triomphe"] } +archery = { git = "https://github.com/michaelsproul/archery", branch = "triomphe" } serde = { version = "1.0.149", optional = true, default-features = false } [dev-dependencies] @@ -56,6 +56,7 @@ static_assertions = "1.1.0" default = ["std"] fatal-warnings = [] std = [] +triomphe-bench = ["archery/triomphe"] [package.metadata.docs.rs] features = ["serde"] @@ -72,10 +73,6 @@ harness = false name = "rpds_list_sync" harness = false -[[bench]] -name = "rpds_list_triomphe" -harness = false - [[bench]] name = "std_vec" harness = false diff --git a/benches/rpds_hash_trie_map_sync.rs b/benches/rpds_hash_trie_map_sync.rs index 359aac7..e6a12ec 100644 --- a/benches/rpds_hash_trie_map_sync.rs +++ b/benches/rpds_hash_trie_map_sync.rs @@ -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 = rpds::HashTrieMapSync; +#[cfg(feature = "triomphe-bench")] +type HashTrieMapSync = rpds::HashTrieMap; + 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)); @@ -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)); @@ -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)); @@ -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)); @@ -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)); @@ -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)); diff --git a/benches/rpds_list_sync.rs b/benches/rpds_list_sync.rs index 1a8dba1..42b84b6 100644 --- a/benches/rpds_list_sync.rs +++ b/benches/rpds_list_sync.rs @@ -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 triomphe::ListSync; +#[cfg(feature = "triomphe-bench")] +type ListSync = rpds::List; + 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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list = list.push_front(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); @@ -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 = ListSync::new_sync(); + let mut list: ListSync = ListSync::new_with_ptr_kind(); for i in 0..limit { list.push_front_mut(i); diff --git a/benches/rpds_list_triomphe.rs b/benches/rpds_list_triomphe.rs deleted file mode 100644 index cef561a..0000000 --- a/benches/rpds_list_triomphe.rs +++ /dev/null @@ -1,172 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#![cfg_attr(feature = "fatal-warnings", deny(warnings))] - -use archery::ArcTK; -use criterion::{criterion_group, criterion_main, Criterion}; -use rpds::List; -use std::hint::black_box; - -fn rpds_list_triomphe_push_front(c: &mut Criterion) { - let limit = 10_000; - - c.bench_function("rpds list sync push front", move |b| { - b.iter(|| { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list = list.push_front(i); - } - - list - }) - }); -} - -fn rpds_list_triomphe_push_front_mut(c: &mut Criterion) { - let limit = 10_000; - - c.bench_function("rpds list sync push front mut", move |b| { - b.iter(|| { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - list - }) - }); -} - -fn rpds_list_triomphe_drop_first(c: &mut Criterion) { - let limit = 10_000; - - c.bench_function("rpds list sync drop first", move |b| { - b.iter_with_setup( - || { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - list - }, - |mut list| { - for _ in 0..limit { - list = list.drop_first().unwrap(); - } - - list - }, - ); - }); -} - -fn rpds_list_triomphe_drop_first_mut(c: &mut Criterion) { - let limit = 10_000; - - c.bench_function("rpds list sync drop first mut", move |b| { - b.iter_with_setup( - || { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - list - }, - |mut list| { - for _ in 0..limit { - list.drop_first_mut(); - } - - list - }, - ); - }); -} - -fn rpds_list_triomphe_reverse(c: &mut Criterion) { - let limit = 1_000; - - c.bench_function("rpds list sync reverse", move |b| { - b.iter_with_setup( - || { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - list - }, - |mut list| { - for _ in 0..limit { - list = list.reverse(); - } - - list - }, - ); - }); -} - -fn rpds_list_triomphe_reverse_mut(c: &mut Criterion) { - let limit = 1_000; - - c.bench_function("rpds list sync reverse mut", move |b| { - b.iter_with_setup( - || { - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - list - }, - |mut list| { - for _ in 0..limit { - list.reverse_mut(); - } - - list - }, - ); - }); -} - -fn rpds_list_triomphe_iterate(c: &mut Criterion) { - let limit = 10_000; - let mut list: List = List::new_with_ptr_kind(); - - for i in 0..limit { - list.push_front_mut(i); - } - - c.bench_function("rpds list sync iterate", move |b| { - b.iter(|| { - for i in list.iter() { - black_box(i); - } - }) - }); -} - -criterion_group!( - benches, - rpds_list_triomphe_push_front, - rpds_list_triomphe_push_front_mut, - rpds_list_triomphe_drop_first, - rpds_list_triomphe_drop_first_mut, - rpds_list_triomphe_reverse, - rpds_list_triomphe_reverse_mut, - rpds_list_triomphe_iterate -); -criterion_main!(benches); diff --git a/benches/rpds_queue_sync.rs b/benches/rpds_queue_sync.rs index 9c6cd2a..ab638d9 100644 --- a/benches/rpds_queue_sync.rs +++ b/benches/rpds_queue_sync.rs @@ -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 = rpds::Queue; + 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 = QueueSync::new_sync(); + let mut queue: QueueSync = QueueSync::new_with_ptr_kind(); for i in 0..limit { queue = queue.enqueue(i); @@ -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 = QueueSync::new_sync(); + let mut queue: QueueSync = QueueSync::new_with_ptr_kind(); for i in 0..limit { queue.enqueue_mut(i); @@ -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 = QueueSync::new_sync(); + let mut queue: QueueSync = QueueSync::new_with_ptr_kind(); for i in 0..limit { queue.enqueue_mut(i); @@ -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 = QueueSync::new_sync(); + let mut queue: QueueSync = QueueSync::new_with_ptr_kind(); for i in 0..limit { queue.enqueue_mut(i); @@ -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 = QueueSync::new_sync(); + let mut queue: QueueSync = QueueSync::new_with_ptr_kind(); for i in 0..limit { queue.enqueue_mut(i); diff --git a/benches/rpds_red_black_tree_map_sync.rs b/benches/rpds_red_black_tree_map_sync.rs index 825a30a..0c3e5ed 100644 --- a/benches/rpds_red_black_tree_map_sync.rs +++ b/benches/rpds_red_black_tree_map_sync.rs @@ -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 = rpds::RedBlackTreeMap; + 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)); @@ -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)); @@ -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)); @@ -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)); @@ -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)); @@ -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)); diff --git a/benches/rpds_vector_sync.rs b/benches/rpds_vector_sync.rs index 5667ea3..bd7a4fd 100644 --- a/benches/rpds_vector_sync.rs +++ b/benches/rpds_vector_sync.rs @@ -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 = rpds::Vector; + 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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector = vector.push_back(i); @@ -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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector.push_back_mut(i); @@ -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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector.push_back_mut(i); @@ -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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector.push_back_mut(i); @@ -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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector.push_back_mut(i); @@ -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 = VectorSync::new_sync(); + let mut vector: VectorSync = VectorSync::new_with_ptr_kind(); for i in 0..limit { vector.push_back_mut(i);