-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test and fix interleaved host audio recv/send
- Loading branch information
Nico Chatzi
committed
Sep 23, 2023
1 parent
2132a9b
commit 4637a2c
Showing
22 changed files
with
1,285 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#[cfg(feature = "bench")] | ||
mod bench { | ||
use aud_lib::audio::*; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use crossbeam::channel::unbounded; | ||
use rand::random; | ||
use std::iter::repeat_with; | ||
|
||
fn bench_enqueue(c: &mut Criterion) { | ||
for buffer_size in [128, 256, 512, 1024] { | ||
let mut group = c.benchmark_group(format!("Enqueue Mono Buffer Size {}", buffer_size)); | ||
group.bench_function("Mono", |b| { | ||
let (sender, _receiver) = unbounded(); | ||
let input_channels = 1; | ||
let selected_channels = vec![0]; | ||
let enqueue_fn = test_make_audio_buffer_enqueueing_function( | ||
sender, | ||
input_channels, | ||
selected_channels, | ||
); | ||
let audio_buffer: Vec<f32> = repeat_with(|| random::<f32>()) | ||
.take(buffer_size * input_channels) | ||
.collect(); | ||
b.iter(|| { | ||
enqueue_fn(&audio_buffer); | ||
}); | ||
}); | ||
group.finish(); | ||
} | ||
} | ||
|
||
fn bench_dequeue(c: &mut Criterion) { | ||
for buffer_size in [128, 256, 512, 1024] { | ||
let mut group = | ||
c.benchmark_group(format!("Dequeue Stereo Buffer Size {}", buffer_size)); | ||
group.bench_function("Stereo", |b| { | ||
let (_sender, receiver) = unbounded(); | ||
let total_channels = 2; | ||
let selected_channels = vec![0, 1]; | ||
let dequeue_fn = | ||
test_make_audio_dequeing_function(receiver, total_channels, selected_channels); | ||
let mut audio_buffer: Vec<f32> = vec![0.0; buffer_size * total_channels]; | ||
b.iter(|| { | ||
dequeue_fn(&mut audio_buffer); | ||
}); | ||
}); | ||
group.finish(); | ||
} | ||
} | ||
|
||
criterion_group!(host_audio_io, bench_enqueue, bench_dequeue); | ||
criterion_main!(host_audio_io); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.