rust_job_scheduling/benches/job_scheduling.rs
2024-10-30 23:22:44 +01:00

29 lines
926 B
Rust

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rust_job_scheduling::algorithm::*;
use rust_job_scheduling::data::*;
use rust_job_scheduling::Task;
const TEST_DATA: &[(&str, &[Task])] = &[("10 tasks", T_10), ("500 tasks", T_500)];
const TEST_FUNCS: &[(&str, &dyn Fn(&[Task]))] = &[
("single thread", &single_thread),
("lpt", &lpt),
("rayon", &rayon),
("rayon sorted", &rayon_sorted),
("rayon sorted reverse", &rayon_sorted_reverse),
("rayon sorted reverse 2", &rayon_sorted_reverse_2),
];
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);