mirror of
https://github.com/RustAudio/rodio
synced 2024-12-13 13:42:34 +00:00
97befac520
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.
21 lines
460 B
Rust
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)
|
|
})
|
|
}
|