From d271dccaba801819a4eae91aaa2e369c5b7535bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 11 Dec 2020 19:08:11 +0100 Subject: [PATCH] cossin bench: be fair to glibc --- dsp/benches/cossin.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dsp/benches/cossin.rs b/dsp/benches/cossin.rs index cbd0499..4e23774 100644 --- a/dsp/benches/cossin.rs +++ b/dsp/benches/cossin.rs @@ -1,12 +1,12 @@ +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 z = -0x7304_2531_i32; - c.bench_function("cossin(z)", |b| b.iter(|| cossin(black_box(z)))); - c.bench_function("(z as f32).sin_cos()", |b| { - b.iter(|| (black_box(z) as f32).sin_cos()) - }); + 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);