Compare commits

..

No commits in common. "1431af6f51a0b76ac370129702b88915d92afb34" and "d8f34487dc1eca3af07c4e31b14b55572339e9cd" have entirely different histories.

6 changed files with 10 additions and 2036 deletions

View file

@ -59,18 +59,3 @@ algorithms in Rust and benchmark them. Let the battle begin.
[rust]: https://www.rust-lang.org/ [rust]: https://www.rust-lang.org/
[gnuplot]: http://www.gnuplot.info/ [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

View file

@ -1,14 +1,13 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rust_job_scheduling::algorithm::*; use rust_job_scheduling::algorithm::*;
use rust_job_scheduling::data::*; use rust_job_scheduling::data::SMALL;
use rust_job_scheduling::Task; 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]))] = &[ const TEST_FUNCS: &[(&str, &dyn Fn(&[Task]))] = &[
("single thread", &single_thread), ("single thread", &single_thread),
("rayon", &rayon), ("rayon", &rayon),
("rayon sorted", &rayon_sorted), ("rayon sorted", &rayon_sorted),
("rayon sorted reverse", &rayon_sorted_reverse),
]; ];
fn job_scheduling_benchmark(c: &mut Criterion) { fn job_scheduling_benchmark(c: &mut Criterion) {

View file

@ -7,14 +7,6 @@ pub fn rayon(data: &[Task]) {
pub fn rayon_sorted(data: &[Task]) { pub fn rayon_sorted(data: &[Task]) {
let mut data = data.to_vec(); let mut data = data.to_vec();
// Shortest tasks first
data.sort(); 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);
} }

View file

@ -1,5 +1,3 @@
mod t10; mod small;
mod t500;
pub use t10::T_10; pub use small::SMALL;
pub use t500::T_500;

View file

@ -1,6 +1,10 @@
use crate::Task; use crate::Task;
pub const T_10: &[Task] = &[ pub const SMALL: &[Task] = &[
Task {
data: b"eb17a235c386039c41c65bf5",
cost: 500,
},
Task { Task {
data: b"df33fd171cd4d311775ebe76", data: b"df33fd171cd4d311775ebe76",
cost: 100, cost: 100,

File diff suppressed because it is too large Load diff