add atan2 host benchmark
This commit is contained in:
parent
17cf71f22b
commit
3125365a15
|
@ -12,7 +12,7 @@ serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "cossin"
|
name = "trig"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
use core::f32::consts::PI;
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
||||||
use dsp::trig::cossin;
|
|
||||||
|
|
||||||
fn cossin_bench(c: &mut Criterion) {
|
|
||||||
let zi = -0x7304_2531_i32;
|
|
||||||
let zf = zi as f32 / i32::MAX as f32 * PI;
|
|
||||||
c.bench_function("cossin(zi)", |b| b.iter(|| cossin(black_box(zi))));
|
|
||||||
c.bench_function("zf.sin_cos()", |b| b.iter(|| black_box(zf).sin_cos()));
|
|
||||||
}
|
|
||||||
|
|
||||||
criterion_group!(benches, cossin_bench);
|
|
||||||
criterion_main!(benches);
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
use core::f32::consts::PI;
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use dsp::trig::{atan2, cossin};
|
||||||
|
|
||||||
|
fn atan2_bench(c: &mut Criterion) {
|
||||||
|
let xi = (10 << 16) as i32;
|
||||||
|
let xf = xi as f32 / i32::MAX as f32;
|
||||||
|
|
||||||
|
let yi = (-26_328 << 16) as i32;
|
||||||
|
let yf = yi as f32 / i32::MAX as f32;
|
||||||
|
|
||||||
|
c.bench_function("atan2(y, x)", |b| {
|
||||||
|
b.iter(|| atan2(black_box(yi), black_box(xi)))
|
||||||
|
});
|
||||||
|
c.bench_function("y.atan2(x)", |b| {
|
||||||
|
b.iter(|| black_box(yf).atan2(black_box(xf)))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cossin_bench(c: &mut Criterion) {
|
||||||
|
let zi = -0x7304_2531_i32;
|
||||||
|
let zf = zi as f32 / i32::MAX as f32 * PI;
|
||||||
|
c.bench_function("cossin(zi)", |b| b.iter(|| cossin(black_box(zi))));
|
||||||
|
c.bench_function("zf.sin_cos()", |b| b.iter(|| black_box(zf).sin_cos()));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, atan2_bench, cossin_bench);
|
||||||
|
criterion_main!(benches);
|
Loading…
Reference in New Issue