-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now
List
abstracts from the pointer type (Rc
/Arc
).
- Loading branch information
Showing
12 changed files
with
475 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* 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 criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use rpds::ListSync; | ||
|
||
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(); | ||
|
||
for i in 0..limit { | ||
list = list.push_front(i); | ||
} | ||
|
||
list | ||
}) | ||
}); | ||
} | ||
|
||
fn rpds_list_sync_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: ListSync<usize> = ListSync::new_sync(); | ||
|
||
for i in 0..limit { | ||
list.push_front_mut(i); | ||
} | ||
|
||
list | ||
}) | ||
}); | ||
} | ||
|
||
fn rpds_list_sync_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: ListSync<usize> = ListSync::new_sync(); | ||
|
||
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_sync_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: ListSync<usize> = ListSync::new_sync(); | ||
|
||
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_sync_reverse(c: &mut Criterion) { | ||
let limit = 1_000; | ||
|
||
c.bench_function("rpds list sync reverse", move |b| { | ||
b.iter_with_setup( | ||
|| { | ||
let mut list: ListSync<usize> = ListSync::new_sync(); | ||
|
||
for i in 0..limit { | ||
list.push_front_mut(i); | ||
} | ||
|
||
list | ||
}, | ||
|mut list| { | ||
for _ in 0..limit { | ||
list = list.reverse(); | ||
} | ||
|
||
list | ||
}, | ||
); | ||
}); | ||
} | ||
|
||
fn rpds_list_sync_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: ListSync<usize> = ListSync::new_sync(); | ||
|
||
for i in 0..limit { | ||
list.push_front_mut(i); | ||
} | ||
|
||
list | ||
}, | ||
|mut list| { | ||
for _ in 0..limit { | ||
list.reverse_mut(); | ||
} | ||
|
||
list | ||
}, | ||
); | ||
}); | ||
} | ||
|
||
fn rpds_list_sync_iterate(c: &mut Criterion) { | ||
let limit = 10_000; | ||
let mut list: ListSync<usize> = ListSync::new_sync(); | ||
|
||
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_sync_push_front, | ||
rpds_list_sync_push_front_mut, | ||
rpds_list_sync_drop_first, | ||
rpds_list_sync_drop_first_mut, | ||
rpds_list_sync_reverse, | ||
rpds_list_sync_reverse_mut, | ||
rpds_list_sync_iterate | ||
); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.