Skip to content

Commit

Permalink
ARROW-9604: [C++] Add aggregate min/max benchmark
Browse files Browse the repository at this point in the history
Add benchmark for aggregate min/max compute kernels

Signed-off-by: Frank Du <frank.du@intel.com>

Closes #7870 from jianxind/min_max_bm

Lead-authored-by: Frank Du <frank.du@intel.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
frankdjx and pitrou committed Aug 12, 2020
1 parent e1e3188 commit faee652
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cpp/src/arrow/compute/kernels/aggregate_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,34 @@ MODE_KERNEL_BENCHMARK(ModeKernelInt16, Int16Type);
MODE_KERNEL_BENCHMARK(ModeKernelInt32, Int32Type);
MODE_KERNEL_BENCHMARK(ModeKernelInt64, Int64Type);

template <typename ArrowType>
static void MinMaxKernelBench(benchmark::State& state) {
using CType = typename TypeTraits<ArrowType>::CType;

RegressionArgs args(state);
const int64_t array_size = args.size / sizeof(CType);
auto rand = random::RandomArrayGenerator(1923);
auto array = rand.Numeric<ArrowType>(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<Type>(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

0 comments on commit faee652

Please sign in to comment.