# Benchmarks
`cargo bench --bench read_throughput` regenerates the 5.3 MB perf fixture
(30 s stereo i16 LCG noise), writes it to a temporary file, and times three
full decodes, best of 10 runs each. In release builds the run fails when
either reader path exceeds 3x the raw decode.
Measured 2026-08-21, macOS arm64 (Apple silicon), rustc 1.97.1, release
(`cargo bench --bench read_throughput`, best of 10):
| raw `fs::read` + `chunks_exact` decode | 4.77 ms | 1059 MiB/s | 1.00x |
| `WavReader::samples::<i16>()` | 9.02 ms | 560 MiB/s | 1.89x |
| `WavReader::read_samples` | 3.77 ms | 1340 MiB/s | 0.79x |
`tests/perf.rs` runs the same three paths under `cargo test` (best of 7)
with the same 3x bound and checks the decoded checksum against the LCG
generator.
The per-item iterator pays for a `Result` per sample and a `Vec` that grows
without an exact size hint, since a stream cannot promise a lower bound.
`read_samples` decodes whole blocks into the caller's slice and beats the
raw baseline because it skips the intermediate byte buffer.