rodio/benches/conversions.rs
github-actions[bot] 97befac520
Adds benchmarks for effects and type conversions
Benchmarks use the music.wav file, we use *divan* as benchmark harnass.
The time needed to load the wav file is excluded from the benchmark
by preparing the data into a special test Source. That source also
enables converting between formats.

In the future *divan* will add support for structured (json) output.
Then we could integrate with the bencher service to generate benchmark
reports for all PR's and keep a timeseries of performance.
2024-09-29 01:58:31 +02:00

21 lines
460 B
Rust

use cpal::FromSample;
use divan::Bencher;
use rodio::Source;
mod shared;
use shared::TestSource;
fn main() {
divan::main();
}
#[divan::bench(types = [i16, u16, f32])]
fn from_i16_to<T: rodio::Sample + FromSample<i16>>(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.convert_samples::<T>()
.for_each(divan::black_box_drop)
})
}