use criterion::{Criterion, black_box, criterion_group, criterion_main};
use spanda::easing::*;
fn bench_easings(c: &mut Criterion) {
let mut group = c.benchmark_group("easing_functions");
group.bench_function("linear", |b| b.iter(|| linear(black_box(0.5))));
group.bench_function("ease_out_cubic", |b| {
b.iter(|| ease_out_cubic(black_box(0.5)))
});
group.bench_function("ease_in_out_cubic", |b| {
b.iter(|| ease_in_out_cubic(black_box(0.5)))
});
group.bench_function("ease_out_elastic", |b| {
b.iter(|| ease_out_elastic(black_box(0.5)))
});
group.bench_function("ease_out_bounce", |b| {
b.iter(|| ease_out_bounce(black_box(0.5)))
});
group.bench_function("ease_in_out_expo", |b| {
b.iter(|| ease_in_out_expo(black_box(0.5)))
});
group.finish();
c.bench_function("Easing::apply (EaseOutCubic)", |b| {
let easing = Easing::EaseOutCubic;
b.iter(|| easing.apply(black_box(0.5)))
});
c.bench_function("all_named_sweep", |b| {
let variants = Easing::all_named();
b.iter(|| {
for easing in &variants {
let _ = easing.apply(black_box(0.5));
}
})
});
}
criterion_group!(benches, bench_easings);
criterion_main!(benches);