#[macro_use] extern crate criterion; use criterion::{black_box, Criterion}; use flex_alloc_secure::{ boxed::{ProtectedBox, SecureBox, ShieldedBox}, ExposeProtected, }; fn compare(c: &mut Criterion) { c.bench_function("secure box create", |b| b.iter(SecureBox::::default)); c.bench_function("protected box create", |b| { b.iter(ProtectedBox::::default) }); c.bench_function("protected box read uncontested", |b| { b.iter_batched( ProtectedBox::::default, |b| { b.expose_read(|_r| { black_box(()); }); b }, criterion::BatchSize::SmallInput, ) }); c.bench_function("protected box write", |b| { b.iter_batched( ProtectedBox::::default, |mut b| { b.expose_write(|_w| { black_box(()); }); b }, criterion::BatchSize::SmallInput, ) }); c.bench_function("shielded box create", |b| { b.iter(ShieldedBox::::default) }); c.bench_function("shielded box read uncontested", |b| { b.iter_batched( ShieldedBox::::default, |b| { b.expose_read(|_r| { black_box(()); }); b }, criterion::BatchSize::SmallInput, ) }); c.bench_function("shielded box write", |b| { b.iter_batched( ShieldedBox::::default, |mut b| { b.expose_write(|_w| { black_box(()); }); b }, criterion::BatchSize::SmallInput, ) }); } criterion_group!(benches, compare); criterion_main!(benches);