|
| 1 | +#[macro_use] |
| 2 | +extern crate criterion; |
| 3 | +extern crate dev_utils; |
| 4 | + |
| 5 | +use downsample_rs::minmax as minmax_mod; |
| 6 | + |
| 7 | +use criterion::{black_box, Criterion}; |
| 8 | +use dev_utils::{config, utils}; |
| 9 | + |
| 10 | +fn minmax_f32_random_array_long_single_core(c: &mut Criterion) { |
| 11 | + let n = config::ARRAY_LENGTH_LONG; |
| 12 | + let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX); |
| 13 | + c.bench_function("minmax_scal_f32", |b| { |
| 14 | + b.iter(|| minmax_mod::min_max_scalar(black_box(data.view()), black_box(2_000))) |
| 15 | + }); |
| 16 | + c.bench_function("minmax_simd_f32", |b| { |
| 17 | + b.iter(|| minmax_mod::min_max_simd(black_box(data.view()), black_box(2_000))) |
| 18 | + }); |
| 19 | +} |
| 20 | + |
| 21 | +fn minmax_f32_random_array_long_multi_core(c: &mut Criterion) { |
| 22 | + let n = config::ARRAY_LENGTH_LONG; |
| 23 | + let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX); |
| 24 | + c.bench_function("minmax_scal_p_f32", |b| { |
| 25 | + b.iter(|| minmax_mod::min_max_scalar_parallel(black_box(data.view()), black_box(2_000))) |
| 26 | + }); |
| 27 | + c.bench_function("minmax_simd_p_f32", |b| { |
| 28 | + b.iter(|| minmax_mod::min_max_simd_parallel(black_box(data.view()), black_box(2_000))) |
| 29 | + }); |
| 30 | +} |
| 31 | + |
| 32 | +fn minmax_f32_random_array_50M_single_core(c: &mut Criterion) { |
| 33 | + let n = 50_000_000; |
| 34 | + let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX); |
| 35 | + c.bench_function("minmax_scal_50M_f32", |b| { |
| 36 | + b.iter(|| minmax_mod::min_max_scalar(black_box(data.view()), black_box(2_000))) |
| 37 | + }); |
| 38 | + c.bench_function("minmax_simd_50M_f32", |b| { |
| 39 | + b.iter(|| minmax_mod::min_max_simd(black_box(data.view()), black_box(2_000))) |
| 40 | + }); |
| 41 | +} |
| 42 | + |
| 43 | +fn minmax_f32_random_array_50M_long_multi_core(c: &mut Criterion) { |
| 44 | + let n = 50_000_000; |
| 45 | + let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX); |
| 46 | + c.bench_function("minmax_scal_p_50M_f32", |b| { |
| 47 | + b.iter(|| minmax_mod::min_max_scalar_parallel(black_box(data.view()), black_box(2_000))) |
| 48 | + }); |
| 49 | + c.bench_function("minmax_simd_p_50M_f32", |b| { |
| 50 | + b.iter(|| minmax_mod::min_max_simd_parallel(black_box(data.view()), black_box(2_000))) |
| 51 | + }); |
| 52 | +} |
| 53 | + |
| 54 | +// fn minmax_f32_worst_case_array_long(c: &mut Criterion) { |
| 55 | +// let n = config::ARRAY_LENGTH_LONG; |
| 56 | +// let data = utils::get_worst_case_array::<f32>(n, 1.0); |
| 57 | +// c.bench_function("overlap_worst_long_f32", |b| { |
| 58 | +// b.iter(|| minmax_mod::min_max_overlap(black_box(data.view()), black_box(2_000))) |
| 59 | +// }); |
| 60 | +// c.bench_function("simple_worst_long_f32", |b| { |
| 61 | +// b.iter(|| minmax_mod::min_max(black_box(data.view()), black_box(2_000))) |
| 62 | +// }); |
| 63 | +// c.bench_function("simd_worst_long_f32", |b| { |
| 64 | +// b.iter(|| minmax_mod::min_max_simd_f32(black_box(data.view()), black_box(2_000))) |
| 65 | +// }); |
| 66 | +// } |
| 67 | + |
| 68 | +criterion_group!( |
| 69 | + benches, |
| 70 | + // minmax_f32_random_array_long_single_core, |
| 71 | + // minmax_f32_random_array_long_multi_core, |
| 72 | + minmax_f32_random_array_50M_single_core, |
| 73 | + minmax_f32_random_array_50M_long_multi_core, |
| 74 | + // minmax_f32_worst_case_array_long, |
| 75 | +); |
| 76 | +criterion_main!(benches); |
0 commit comments