Skip to content

Commit

Permalink
ARROW-11346: [C++][Compute] Implement quantile kernel benchmark
Browse files Browse the repository at this point in the history
Closes #9292 from cyb70289/quantile-bench

Authored-by: Yibo Cai <yibo.cai@arm.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
cyb70289 authored and pitrou committed Jan 26, 2021
1 parent 2cb8ef0 commit e3df397
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cpp/src/arrow/compute/kernels/aggregate_benchmark.cc
Expand Up @@ -457,5 +457,36 @@ VARIANCE_KERNEL_BENCHMARK(VarianceKernelInt64, Int64Type);
VARIANCE_KERNEL_BENCHMARK(VarianceKernelFloat, FloatType);
VARIANCE_KERNEL_BENCHMARK(VarianceKernelDouble, DoubleType);

//
// Quantile
//

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

QuantileOptions options;
RegressionArgs args(state);
const int64_t array_size = args.size / sizeof(CType);
auto rand = random::RandomArrayGenerator(1926);
auto array = rand.Numeric<ArrowType>(array_size, -30000, 30000, args.null_proportion);

for (auto _ : state) {
ABORT_NOT_OK(Quantile(array, options).status());
}
}

static void QuantileKernelBenchArgs(benchmark::internal::Benchmark* bench) {
BenchmarkSetArgsWithSizes(bench, {1 * 1024 * 1024});
}

#define QUANTILE_KERNEL_BENCHMARK(FuncName, Type) \
static void FuncName(benchmark::State& state) { QuantileKernelBench<Type>(state); } \
BENCHMARK(FuncName)->Apply(QuantileKernelBenchArgs)

QUANTILE_KERNEL_BENCHMARK(QuantileKernelInt32, Int32Type);
QUANTILE_KERNEL_BENCHMARK(QuantileKernelInt64, Int64Type);
QUANTILE_KERNEL_BENCHMARK(QuantileKernelDouble, DoubleType);

} // namespace compute
} // namespace arrow

0 comments on commit e3df397

Please sign in to comment.