rust_job_scheduling/benches/job_scheduling.rs

27 lines
784 B
Rust
Raw Normal View History

2024-10-30 21:08:19 +01:00
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rust_job_scheduling::algorithm::*;
2024-10-30 21:54:25 +01:00
use rust_job_scheduling::data::*;
2024-10-30 21:08:19 +01:00
use rust_job_scheduling::Task;
2024-10-30 21:54:25 +01:00
const TEST_DATA: &[(&str, &[Task])] = &[("10 tasks", T_10)];
const TEST_FUNCS: &[(&str, &dyn Fn(&[Task]))] = &[
("single thread", &single_thread),
("rayon", &rayon),
("rayon sorted", &rayon_sorted),
];
2024-10-30 21:08:19 +01:00
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);