Files
songbird/benches/base-mixing.rs
Kyle Simpson 504b8dfaef Driver, Input: Performance & Benchmarks (#27)
* Driver Benchmarks

Benchmarks driver use cases for single packet send,
multiple packet send, float vs opus, and the cost of
head-of-queue track removal.

Mix costs for large packet counts are also included.

This is a prelude to the optimisations discussed in
#21.

* Typo in benchmark

* Place Opus packet directly into packet buffer

Cleans up some other logic surrounding this, too. Gets a 16.9% perf improvement on opus packet passthrough (sub 5us here).

* Better track removal

In theory this should be faster, but it aint. Keeping in case
reducing struct sizes down the line magically makes this
faster.

* Reduce size of Input, TrackHandle

Metadata is now boxed away. Similarly, TrackHandles are neatly Arc'd to reduce their size to pointer length (and mitigate the impact of copies if we add in more fields).
2020-12-26 23:08:35 +00:00

31 lines
965 B
Rust

use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
use songbird::{constants::*, input::Input};
pub fn mix_one_frame(c: &mut Criterion) {
let floats = utils::make_sine(STEREO_FRAME_SIZE, true);
let mut raw_buf = [0f32; STEREO_FRAME_SIZE];
c.bench_function("Mix stereo source", |b| {
b.iter_batched_ref(
|| black_box(Input::float_pcm(true, floats.clone().into())),
|input| {
input.mix(black_box(&mut raw_buf), black_box(1.0));
},
BatchSize::SmallInput,
)
});
c.bench_function("Mix mono source", |b| {
b.iter_batched_ref(
|| black_box(Input::float_pcm(false, floats.clone().into())),
|input| {
input.mix(black_box(&mut raw_buf), black_box(1.0));
},
BatchSize::SmallInput,
)
});
}
criterion_group!(benches, mix_one_frame);
criterion_main!(benches);