You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/08/12 17:10:36 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #7870: ARROW-9604: [C++] Add aggregate min/max benchmark

pitrou commented on a change in pull request #7870:
URL: https://github.com/apache/arrow/pull/7870#discussion_r469412632



##########
File path: cpp/src/arrow/compute/kernels/aggregate_benchmark.cc
##########
@@ -369,5 +369,51 @@ 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);
+
+static void CountKernelInt64(benchmark::State& state) {

Review comment:
       I don't think it's important to benchmark the `count` kernel. It's a trivial `O(1)` kernel.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org