scratch/2021-07-11/array-queue/benches/benchmarks.rs

18 lines
471 B
Rust
Raw Normal View History

2021-08-26 07:38:39 +00:00
use array_queue::ArrayQueue;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
fn push_pop_50(mut queue: ArrayQueue<u8, 100>) {
for _ in 0..50 {
queue.push(5);
let _ = queue.pop();
}
}
fn criterion_benchmark(c: &mut Criterion) {
let queue = ArrayQueue::default();
c.bench_function("push/pull 50", |b| b.iter(move || push_pop_50(queue)));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);