Skip to content

Commit

Permalink
Keep sample conversion bench
Browse files Browse the repository at this point in the history
This may estimate additional load from onversions,
althoug it is now less useful since f32 samples are used almost
everythere.
  • Loading branch information
PetrGlad committed Feb 22, 2025
1 parent 1cbce53 commit f69ec88
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions benches/conversions.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
use dasp_sample::FromSample;
use dasp_sample::{Duplex, Sample};
use divan::Bencher;
use rodio::{decoder::DecoderSample, Source};
use rodio::conversions::SampleTypeConverter;

mod shared;

fn main() {
divan::main();
}

// #[divan::bench(types = [i16, u16, f32])]
// fn from_sample_to(bencher: Bencher) {
// bencher
// .with_inputs(|| shared::music_wav())
// .bench_values(|source| source.for_each(divan::black_box_drop))
// }
#[divan::bench(types = [i16, u16, f32])]
fn from_sample<S: Duplex<f32>>(bencher: Bencher) {
bencher
.with_inputs(|| {
shared::music_wav()
.map(|s| s.to_sample::<S>())
.collect::<Vec<_>>()
.into_iter()
})
.bench_values(|source| {
SampleTypeConverter::<_, rodio::Sample>::new(source).for_each(divan::black_box_drop)
})
}

0 comments on commit f69ec88

Please sign in to comment.