Skip to content

Commit

Permalink
Expand benchmarks using triomphe-bench feature
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Oct 25, 2023
1 parent 8dd589a commit 63d8255
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 212 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -56,6 +56,7 @@ static_assertions = "1.1.0"
default = ["std"]
fatal-warnings = []
std = []
triomphe-bench = ["archery/triomphe"]

[package.metadata.docs.rs]
features = ["serde"]
Expand All @@ -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
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 triomphe::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
172 changes: 0 additions & 172 deletions benches/rpds_list_triomphe.rs

This file was deleted.

Loading

0 comments on commit 63d8255

Please sign in to comment.