Rename the benchmark

This commit is contained in:
Rodolphe Bréard 2024-10-30 21:08:19 +01:00
parent 06573ed2a0
commit a6afc0b406
3 changed files with 23 additions and 13 deletions

View file

@ -15,5 +15,5 @@ sha2 = "0.10.8"
criterion = { version = "0.5.1", features = ["html_reports"] }
[[bench]]
name = "small"
name = "job_scheduling"
harness = false

22
benches/job_scheduling.rs Normal file
View file

@ -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);

View file

@ -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);