From db56ea6fe4fc189a10e1776b26bace7d8497fff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 27 Oct 2024 19:37:24 +0100 Subject: [PATCH] Add a first benchmark --- Cargo.toml | 7 +++++++ benches/small.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 benches/small.rs diff --git a/Cargo.toml b/Cargo.toml index dbd6d27..c638765 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,10 @@ publish = false [dependencies] pbkdf2 = "0.12.2" sha2 = "0.10.8" + +[dev-dependencies] +criterion = { version = "0.5.1", features = ["html_reports"] } + +[[bench]] +name = "small" +harness = false diff --git a/benches/small.rs b/benches/small.rs new file mode 100644 index 0000000..34f546e --- /dev/null +++ b/benches/small.rs @@ -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);