Skip to content

Commit

Permalink
Criterion testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhovd committed Feb 12, 2025
1 parent 582d053 commit 48c27f0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 258 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ codegen-units = 1
opt-level = 3

[dev-dependencies]
diol = "0.8.2"
criterion = { version = "0.5" }

[[bench]]
name = "fibonacci"
harness = false
name = "compare"
256 changes: 0 additions & 256 deletions benches/compare.rs

This file was deleted.

17 changes: 17 additions & 0 deletions benches/fibonacci.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use criterion::{criterion_group, criterion_main, Criterion};
use std::hint::black_box;

fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n - 1) + fibonacci(n - 2),
}
}

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

0 comments on commit 48c27f0

Please sign in to comment.