diff options
Diffstat (limited to 'src/tests/example_stack')
-rw-r--r-- | src/tests/example_stack/Cargo.toml | 5 | ||||
-rw-r--r-- | src/tests/example_stack/benches/do_stuff.rs | 12 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/tests/example_stack/Cargo.toml b/src/tests/example_stack/Cargo.toml index 3e3e617..55e4338 100644 --- a/src/tests/example_stack/Cargo.toml +++ b/src/tests/example_stack/Cargo.toml @@ -8,6 +8,9 @@ edition = "2021" [dependencies] primrose-library = { path = "../../crates/library" } +[dev-dependencies] +criterion = { workspace = true } + [[bench]] name = "do_stuff" -harness = false
\ No newline at end of file +harness = false diff --git a/src/tests/example_stack/benches/do_stuff.rs b/src/tests/example_stack/benches/do_stuff.rs index 69d50d5..c7e2e23 100644 --- a/src/tests/example_stack/benches/do_stuff.rs +++ b/src/tests/example_stack/benches/do_stuff.rs @@ -1,6 +1,8 @@ -fn main() { - // TODO: some actual benchmarking, not just a random loop - for _ in 0..20 { - example_stack::do_something(); - } +use criterion::{criterion_group, criterion_main, Criterion}; + +fn run_benches(c: &mut Criterion) { + c.bench_function("do_something", |b| b.iter(|| example_stack::do_something())); } + +criterion_group!(benches, run_benches); +criterion_main!(benches); |