Skip to content

Commit c721584

Browse files
committed
benches: add sid benchmarking
1 parent 86b39f6 commit c721584

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ libm = { version = "0.2.0", optional = true }
2626
criterion = "0.2"
2727

2828
[[bench]]
29-
name = "sampler_bench"
29+
name = "main"
3030
harness = false

benches/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[macro_use]
2+
extern crate criterion;
3+
4+
mod sid_bench;
5+
mod sampler_bench;
6+
7+
criterion_group!(benches, sid_bench::bench_sid, sampler_bench::bench_compute_convolution_fir);
8+
9+
criterion_main!(benches);

benches/sampler_bench.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#[macro_use]
2-
extern crate criterion;
3-
41
use criterion::Criterion;
52
use resid::sampler::Sampler;
63
use resid::synth::Synth;
74
use resid::ChipModel;
85

9-
fn bench_compute_convolution_fir(c: &mut Criterion) {
6+
pub fn bench_compute_convolution_fir(c: &mut Criterion) {
107
c.bench_function("convolution_fir", |b| {
118
let sampler = Sampler::new(Synth::new(ChipModel::Mos6581));
129
let samples = [2i16; 1024];
@@ -32,6 +29,3 @@ fn bench_compute_convolution_fir(c: &mut Criterion) {
3229
b.iter(|| sampler.compute_convolution_fir_fallback(&samples[..], &fir[..]))
3330
});
3431
}
35-
36-
criterion_group!(benches, bench_compute_convolution_fir);
37-
criterion_main!(benches);

benches/sid_bench.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use criterion::Criterion;
2+
use resid::{ChipModel, Sid};
3+
4+
pub fn bench_sid(c: &mut Criterion) {
5+
c.bench_function("clock_delta", |b| {
6+
let mut sid = Sid::new(ChipModel::Mos6581);
7+
sid.write(0x05, 0x09); // AD1
8+
sid.write(0x06, 0x00); // SR1
9+
sid.write(0x18, 0x0f); // MODVOL
10+
sid.write(0x01, 25); // FREQHI1
11+
sid.write(0x00, 177); // FREQLO1
12+
sid.write(0x00, 0x21); // CR1
13+
b.iter(|| sid.clock_delta(22))
14+
});
15+
}

src/filter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use core::f64;
99

1010
use super::data::{SPLINE6581_F0, SPLINE8580_F0};
11-
use super::spline;
1211
use super::ChipModel;
1312

1413
const MIXER_DC: i32 = (-0xfff * 0xff / 18) >> 7;

0 commit comments

Comments
 (0)