diff --git a/cpp/src/arrow/compute/kernels/aggregate_benchmark.cc b/cpp/src/arrow/compute/kernels/aggregate_benchmark.cc index 71a11458952..882037f2d5d 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_benchmark.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_benchmark.cc @@ -369,5 +369,34 @@ MODE_KERNEL_BENCHMARK(ModeKernelInt16, Int16Type); MODE_KERNEL_BENCHMARK(ModeKernelInt32, Int32Type); MODE_KERNEL_BENCHMARK(ModeKernelInt64, Int64Type); +template +static void MinMaxKernelBench(benchmark::State& state) { + using CType = typename TypeTraits::CType; + + RegressionArgs args(state); + const int64_t array_size = args.size / sizeof(CType); + auto rand = random::RandomArrayGenerator(1923); + auto array = rand.Numeric(array_size, -100, 100, args.null_proportion); + + for (auto _ : state) { + ABORT_NOT_OK(MinMax(array).status()); + } +} + +static void MinMaxKernelBenchArgs(benchmark::internal::Benchmark* bench) { + BenchmarkSetArgsWithSizes(bench, {1 * 1024 * 1024}); // 1M +} + +#define MINMAX_KERNEL_BENCHMARK(FuncName, Type) \ + static void FuncName(benchmark::State& state) { MinMaxKernelBench(state); } \ + BENCHMARK(FuncName)->Apply(MinMaxKernelBenchArgs) + +MINMAX_KERNEL_BENCHMARK(MinMaxKernelFloat, FloatType); +MINMAX_KERNEL_BENCHMARK(MinMaxKernelDouble, DoubleType); +MINMAX_KERNEL_BENCHMARK(MinMaxKernelInt8, Int8Type); +MINMAX_KERNEL_BENCHMARK(MinMaxKernelInt16, Int16Type); +MINMAX_KERNEL_BENCHMARK(MinMaxKernelInt32, Int32Type); +MINMAX_KERNEL_BENCHMARK(MinMaxKernelInt64, Int64Type); + } // namespace compute } // namespace arrow