// SDD-120 §3 item 5 — resampler throughput bench. // // The chanora_audio engine uses a hand-rolled linear resampler // inside CaptureState (see engine.rs `resample_into_accum`); there // is no rubato dependency. The bench drives the same code path // via the §3 bench seam by instantiating CaptureBenchHandle at // different `in_sample_rate` values (44_100, 16_000, 48_000) and // feeding a 1-second buffer per iteration. Throughput is reported // as samples/sec via criterion's `Throughput::Elements`. use chanora_audio::bench_seam::CaptureBenchHandle; use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; mod common; use common::synthetic_capture_buffer; fn bench_resampler_throughput(c: &mut Criterion) { let mut group = c.benchmark_group("resampler_throughput"); for (label, in_rate, frames) in [ ("44100_to_48000", 44_100u32, 44_100usize), ("16000_to_48000", 16_000u32, 16_000usize), ("48000_passthrough", 48_000u32, 48_000usize), ] { let buf = synthetic_capture_buffer(frames, 1); let mut handle = CaptureBenchHandle::new(in_rate, 1); // Pre-warm so the first allocation does not dominate. for _ in 0..4 { handle.ingest_f32(&buf); } group.throughput(Throughput::Elements(frames as u64)); group.bench_function(label, |b| { b.iter(|| { handle.ingest_f32(black_box(&buf)); }); }); } group.finish(); } criterion_group!(resampler, bench_resampler_throughput); criterion_main!(resampler);