2021-04-21 17:51:51 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
2021-04-22 22:01:09 +00:00
|
|
|
use lofty::Tag;
|
2021-04-21 17:48:21 +00:00
|
|
|
|
|
|
|
macro_rules! test_read {
|
|
|
|
($function:ident, $path:expr) => {
|
|
|
|
fn $function() {
|
2021-04-23 02:57:47 +00:00
|
|
|
Tag::new().read_from_path_signature($path).unwrap();
|
2021-04-21 17:48:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-08 01:26:30 +00:00
|
|
|
test_read!(read_aiff, "tests/assets/a_text.aiff");
|
2021-04-21 17:48:21 +00:00
|
|
|
test_read!(read_ape, "tests/assets/a.ape");
|
|
|
|
test_read!(read_flac, "tests/assets/a.flac");
|
|
|
|
test_read!(read_m4a, "tests/assets/a.m4a");
|
|
|
|
test_read!(read_mp3, "tests/assets/a.mp3");
|
2021-06-27 18:25:29 +00:00
|
|
|
test_read!(read_vorbis, "tests/assets/a.ogg");
|
2021-04-21 17:48:21 +00:00
|
|
|
test_read!(read_opus, "tests/assets/a.opus");
|
2021-06-27 18:25:29 +00:00
|
|
|
test_read!(read_riff, "tests/assets/a.wav");
|
2021-04-21 17:48:21 +00:00
|
|
|
|
|
|
|
fn bench_sig(c: &mut Criterion) {
|
2021-06-26 19:24:59 +00:00
|
|
|
let mut g = c.benchmark_group("From signature");
|
2021-07-08 01:26:30 +00:00
|
|
|
g.bench_function("AIFF", |b| b.iter(read_aiff));
|
2021-06-26 19:24:59 +00:00
|
|
|
g.bench_function("APE", |b| b.iter(read_ape));
|
|
|
|
g.bench_function("FLAC", |b| b.iter(read_flac));
|
|
|
|
g.bench_function("MP4", |b| b.iter(read_m4a));
|
|
|
|
g.bench_function("MP3", |b| b.iter(read_mp3));
|
2021-06-27 18:25:29 +00:00
|
|
|
g.bench_function("VORBIS", |b| b.iter(read_vorbis));
|
2021-06-26 19:24:59 +00:00
|
|
|
g.bench_function("OPUS", |b| b.iter(read_opus));
|
2021-06-27 18:25:29 +00:00
|
|
|
g.bench_function("RIFF", |b| b.iter(read_riff));
|
2021-04-21 17:48:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, bench_sig);
|
|
|
|
criterion_main!(benches);
|