Compare commits
No commits in common. "1431af6f51a0b76ac370129702b88915d92afb34" and "d8f34487dc1eca3af07c4e31b14b55572339e9cd" have entirely different histories.
1431af6f51
...
d8f34487dc
6 changed files with 10 additions and 2036 deletions
15
README.md
15
README.md
|
@ -59,18 +59,3 @@ algorithms in Rust and benchmark them. Let the battle begin.
|
|||
|
||||
[rust]: https://www.rust-lang.org/
|
||||
[gnuplot]: http://www.gnuplot.info/
|
||||
|
||||
|
||||
## Algorithms
|
||||
|
||||
- `single thread`: No multi-threading or any optimization of any kind. Used as
|
||||
a reference.
|
||||
- `rayon`: Multi-threading provided by the `rayon` crate, but no optimization
|
||||
of any kind. Used as a reference.
|
||||
- `rayon sorted`: Multi-threading provided by the `rayon` crate. Tasks are
|
||||
sorted so the shortest ones are executed first.
|
||||
- `rayon sorted reverse`: Multi-threading provided by the `rayon` crate. Tasks
|
||||
are sorted so the longest ones are executed first. This should behave as an
|
||||
[LPT][lpt].
|
||||
|
||||
[lpt]: https://en.wikipedia.org/wiki/Longest-processing-time-first_scheduling
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use rust_job_scheduling::algorithm::*;
|
||||
use rust_job_scheduling::data::*;
|
||||
use rust_job_scheduling::data::SMALL;
|
||||
use rust_job_scheduling::Task;
|
||||
|
||||
const TEST_DATA: &[(&str, &[Task])] = &[("10 tasks", T_10), ("500 tasks", T_500)];
|
||||
const TEST_DATA: &[(&str, &[Task])] = &[("small", SMALL)];
|
||||
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,14 +7,6 @@ pub fn rayon(data: &[Task]) {
|
|||
|
||||
pub fn rayon_sorted(data: &[Task]) {
|
||||
let mut data = data.to_vec();
|
||||
// Shortest tasks first
|
||||
data.sort();
|
||||
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);
|
||||
rayon(&data)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
mod t10;
|
||||
mod t500;
|
||||
mod small;
|
||||
|
||||
pub use t10::T_10;
|
||||
pub use t500::T_500;
|
||||
pub use small::SMALL;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use crate::Task;
|
||||
|
||||
pub const T_10: &[Task] = &[
|
||||
pub const SMALL: &[Task] = &[
|
||||
Task {
|
||||
data: b"eb17a235c386039c41c65bf5",
|
||||
cost: 500,
|
||||
},
|
||||
Task {
|
||||
data: b"df33fd171cd4d311775ebe76",
|
||||
cost: 100,
|
2004
src/data/t500.rs
2004
src/data/t500.rs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue