jhorstmann commented on code in PR #5096:
URL: https://github.com/apache/arrow-rs/pull/5096#discussion_r1398273524
##########
arrow/benches/aggregate_kernels.rs:
##########
@@ -17,50 +17,55 @@
#[macro_use]
extern crate criterion;
-use criterion::Criterion;
+use criterion::{Criterion, Throughput};
+use rand::distributions::{Distribution, Standard};
extern crate arrow;
use arrow::compute::kernels::aggregate::*;
use arrow::util::bench_util::*;
use arrow::{array::*, datatypes::Float32Type};
+use arrow_array::types::{Float64Type, Int16Type, Int32Type, Int64Type,
Int8Type};
-fn bench_sum(arr_a: &Float32Array) {
- criterion::black_box(sum(arr_a).unwrap());
-}
-
-fn bench_min(arr_a: &Float32Array) {
- criterion::black_box(min(arr_a).unwrap());
-}
-
-fn bench_max(arr_a: &Float32Array) {
- criterion::black_box(max(arr_a).unwrap());
-}
+const BATCH_SIZE: usize = 64 * 1024;
-fn bench_min_string(arr_a: &StringArray) {
- criterion::black_box(min_string(arr_a).unwrap());
+fn primitive_benchmark<T: ArrowNumericType>(c: &mut Criterion, name: &str)
+where
+ Standard: Distribution<T::Native>,
+{
+ let nonnull_array = create_primitive_array::<T>(BATCH_SIZE, 0.0);
+ let nullable_array = create_primitive_array::<T>(BATCH_SIZE, 0.5);
+ c.benchmark_group(name)
+ .throughput(Throughput::Bytes(
+ (std::mem::size_of::<T::Native>() * BATCH_SIZE) as u64,
+ ))
+ .bench_function("sum nonnull", |b| b.iter(|| sum(&nonnull_array)))
Review Comment:
It is indeed always wrapping, scalar version goes through
`ArrowNativeTypeOp::add_wrapping` and I guess the simd version wraps by
default. There seems to be a separate `sum_checked` kernels, I'm not sure yet
whether that could be vectorized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]