Compare commits

..

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

6 changed files with 16 additions and 44 deletions

View file

@ -9,12 +9,11 @@ publish = false
[dependencies]
pbkdf2 = "0.12.2"
rayon = { version = "1.10.0", default-features = false }
sha2 = "0.10.8"
[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
[[bench]]
name = "job_scheduling"
name = "small"
harness = false

View file

@ -23,8 +23,9 @@ the [optimal job scheduling problem][ojs problem] and can often be seen as a
### Example
We have 4 tasks tasks to execute. Three of them takes 1 second each to execute
and the last one takes 3 seconds. We have 2 processing units of equal power.
If we have 4 tasks tasks to execute. Three of then takes 1 second each to
execute and the last one takes 3 seconds. We have 2 processing units of equal
power.
If each processing unit starts by executing one of the 1s tasks, they will both
finis this job after one second. Then, one of those processing unit will

View file

@ -1,26 +0,0 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rust_job_scheduling::algorithm::*;
use rust_job_scheduling::data::SMALL;
use rust_job_scheduling::Task;
const TEST_DATA: &[(&str, &[Task])] = &[("small", SMALL)];
const TEST_FUNCS: &[(&str, &dyn Fn(&[Task]))] = &[
("single thread", &single_thread),
("rayon", &rayon),
("rayon sorted", &rayon_sorted),
];
fn job_scheduling_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("job_scheduling");
for (data_name, data) in TEST_DATA {
for (func_name, func) in TEST_FUNCS {
group.bench_with_input(BenchmarkId::new(*func_name, data_name), data, |b, i| {
b.iter(|| func(i))
});
}
}
group.finish();
}
criterion_group!(benches, job_scheduling_benchmark);
criterion_main!(benches);

12
benches/small.rs Normal file
View file

@ -0,0 +1,12 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rust_job_scheduling::algorithm::*;
use rust_job_scheduling::data::SMALL;
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("single thread", |b| {
b.iter(|| single_thread(black_box(SMALL)))
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

View file

@ -1,5 +1,3 @@
mod rayon;
mod single_thread;
pub use rayon::{rayon, rayon_sorted};
pub use single_thread::single_thread;

View file

@ -1,12 +0,0 @@
use crate::Task;
use rayon::prelude::*;
pub fn rayon(data: &[Task]) {
data.into_par_iter().for_each(|task| task.execute());
}
pub fn rayon_sorted(data: &[Task]) {
let mut data = data.to_vec();
data.sort();
rayon(&data)
}