rodio/benches/effects.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

48 lines
1.1 KiB
Rust

use std::time::Duration;
use divan::Bencher;
use rodio::Source;
mod shared;
use shared::TestSource;
fn main() {
divan::main();
}
#[divan::bench]
fn reverb(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.buffered()
.reverb(Duration::from_secs_f32(0.05), 0.3)
.for_each(divan::black_box_drop)
})
}
#[divan::bench]
fn high_pass(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| source.high_pass(200).for_each(divan::black_box_drop))
}
#[divan::bench]
fn fade_out(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.fade_out(Duration::from_secs(5))
.for_each(divan::black_box_drop)
})
}
#[divan::bench]
fn amplify(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| source.amplify(0.8).for_each(divan::black_box_drop))
}