diff --git a/Cargo.toml b/Cargo.toml index c638765..dafe03c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,5 @@ sha2 = "0.10.8" criterion = { version = "0.5.1", features = ["html_reports"] } [[bench]] -name = "small" +name = "job_scheduling" harness = false diff --git a/benches/job_scheduling.rs b/benches/job_scheduling.rs new file mode 100644 index 0000000..f7f68b8 --- /dev/null +++ b/benches/job_scheduling.rs @@ -0,0 +1,22 @@ +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)]; + +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); diff --git a/benches/small.rs b/benches/small.rs deleted file mode 100644 index 34f546e..0000000 --- a/benches/small.rs +++ /dev/null @@ -1,12 +0,0 @@ -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);