2024-07-30 17:24:39 +00:00
|
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
|
|
|
|
|
|
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);
|
2024-07-31 02:46:15 +00:00
|
|
|
criterion_main!(benches);
|