#![feature(allocator_api)]
use criterion::{black_box, criterion_group, criterion_main, Criterion};
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("arena 1000", |b| b.iter(|| {
let alloc = local_alloc::Arena::new(1024);
local_alloc::traits::benches::run_arena(black_box(alloc), black_box(1000))
}));
c.bench_function("malloc 1000", |b| b.iter(|| {
let alloc = std::alloc::Global;
local_alloc::traits::benches::run_in(black_box(alloc), black_box(1000))
}));
c.bench_function("arena 1000 no reclaim", |b| b.iter(|| {
let alloc = local_alloc::Arena::new(1024 * 1024 * 128);
local_alloc::traits::benches::run_in(black_box(alloc), black_box(1000))
}));
c.bench_function("malloc 1000 dyn", |b| b.iter(|| {
let alloc = std::alloc::Global;
let alloc: &dyn std::alloc::Allocator = &alloc;
local_alloc::traits::benches::run_in(black_box(alloc), black_box(1000))
}));
c.bench_function("arena 1000 dyn no reclaim", |b| b.iter(|| {
let alloc = local_alloc::Arena::new(1024 * 1024 * 128);
let alloc: &dyn std::alloc::Allocator = &alloc;
local_alloc::traits::benches::run_in(black_box(alloc), black_box(1000))
}));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);