Skip to content

Commit 1671d36

Browse files
committed
adds pipeline benchmarks (to see effect of #706)
1 parent 7c02411 commit 1671d36

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ harness = false
7979
name = "resampler"
8080
harness = false
8181

82+
[[bench]]
83+
name = "pipeline"
84+
harness = false
85+
8286
[[example]]
8387
name = "music_m4a"
8488
required-features = ["symphonia-isomp4", "symphonia-aac"]

benches/pipeline.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use std::time::Duration;
2+
3+
use divan::Bencher;
4+
use rodio::{source::UniformSourceIterator, Source};
5+
6+
mod shared;
7+
use shared::music_wav;
8+
9+
fn main() {
10+
divan::main();
11+
}
12+
13+
#[divan::bench]
14+
fn long(bencher: Bencher) {
15+
bencher.with_inputs(|| music_wav()).bench_values(|source| {
16+
let mut take_dur = source
17+
.high_pass(300)
18+
.amplify(1.2)
19+
.speed(0.9)
20+
.automatic_gain_control(
21+
1.0, // target_level
22+
4.0, // attack_time (in seconds)
23+
0.005, // release_time (in seconds)
24+
5.0, // absolute_max_gain
25+
)
26+
.delay(Duration::from_secs_f32(0.5))
27+
.fade_in(Duration::from_secs_f32(2.0))
28+
.take_duration(Duration::from_secs(10));
29+
take_dur.set_filter_fadeout();
30+
let effects_applied = take_dur
31+
.buffered()
32+
.reverb(Duration::from_secs_f32(0.05), 0.3)
33+
.skippable();
34+
let resampled = UniformSourceIterator::new(effects_applied, 2, 40_000);
35+
resampled.for_each(divan::black_box_drop)
36+
})
37+
}
38+
39+
#[divan::bench]
40+
fn short(bencher: Bencher) {
41+
bencher.with_inputs(|| music_wav()).bench_values(|source| {
42+
source
43+
.amplify(1.2)
44+
.low_pass(200)
45+
.for_each(divan::black_box_drop)
46+
})
47+
}

0 commit comments

Comments
 (0)