Add the rayon_sorted_reverse algorithm
This commit is contained in:
parent
f1e158fb4d
commit
501179f5fd
2 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,7 @@ const TEST_FUNCS: &[(&str, &dyn Fn(&[Task]))] = &[
|
|||
("single thread", &single_thread),
|
||||
("rayon", &rayon),
|
||||
("rayon sorted", &rayon_sorted),
|
||||
("rayon sorted reverse", &rayon_sorted_reverse),
|
||||
];
|
||||
|
||||
fn job_scheduling_benchmark(c: &mut Criterion) {
|
||||
|
|
|
@ -7,6 +7,14 @@ pub fn rayon(data: &[Task]) {
|
|||
|
||||
pub fn rayon_sorted(data: &[Task]) {
|
||||
let mut data = data.to_vec();
|
||||
// Shortest tasks first
|
||||
data.sort();
|
||||
rayon(&data)
|
||||
rayon(&data);
|
||||
}
|
||||
|
||||
pub fn rayon_sorted_reverse(data: &[Task]) {
|
||||
let mut data = data.to_vec();
|
||||
// Longest tasks first
|
||||
data.sort_by(|a, b| a.cmp(b).reverse());
|
||||
rayon(&data);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue