-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasic_sort.rs
47 lines (42 loc) · 1.26 KB
/
basic_sort.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rdst::utils::bench_utils::bench_single;
use rdst::utils::test_utils::NumericTest;
use rdst::RadixSort;
fn basic_sort_set<T>(c: &mut Criterion, suffix: &str, shift: T, count: usize)
where
T: NumericTest<T>,
{
let tests: Vec<(&str, Box<dyn Fn(Vec<T>)>)> = vec![
(
"rdst",
Box::new(|mut input| {
input.radix_sort_unstable();
black_box(input);
}),
),
(
"rdst_low_mem",
Box::new(|mut input| {
input.radix_sort_builder().with_low_mem_tuner().sort();
black_box(input);
}),
),
(
"rdst_single_threaded",
Box::new(|mut input| {
input
.radix_sort_builder()
.with_single_threaded_tuner()
.with_parallel(false)
.sort();
black_box(input);
}),
),
];
bench_single(c, &("basic_sort_".to_owned() + suffix), tests, shift, count);
}
fn basic_sort(c: &mut Criterion) {
basic_sort_set(c, "u32", 0u32, 10_000_000);
}
criterion_group!(benches, basic_sort,);
criterion_main!(benches);