#![feature(portable_simd)] #![feature(is_sorted)] use criterion::{black_box, criterion_group, criterion_main, Criterion}; use simd_itertools::MaxSimd; use simd_itertools::SIMD_LEN; use std::fmt::Debug; use std::simd::prelude::SimdPartialEq; use std::simd::Mask; use std::simd::{Simd, SimdElement}; fn benchmark_contains<'a, T: 'static + Copy + PartialEq + Default + Debug>( c: &mut Criterion, name: &str, ) where T: SimdElement + std::cmp::PartialEq + std::cmp::Ord, Simd: SimdPartialEq>, { let len = 10000; let v1 = black_box(vec![T::default(); len]); c.bench_function(&format!("SIMD max {}", name), |b| { b.iter(|| black_box(v1.iter().max_simd())) }); c.bench_function(&format!("trivial max {}", name), |b| { b.iter(|| black_box(v1.iter().max())) }); } fn criterion_benchmark(c: &mut Criterion) { benchmark_contains::(c, "u8"); benchmark_contains::(c, "i8"); benchmark_contains::(c, "u16"); benchmark_contains::(c, "i16"); benchmark_contains::(c, "u32"); benchmark_contains::(c, "i32"); benchmark_contains::(c, "u64"); benchmark_contains::(c, "i64"); benchmark_contains::(c, "isize"); benchmark_contains::(c, "usize"); // benchmark_contains::(c, "f32"); // benchmark_contains::(c, "f64"); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);