]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/cpp/src/arrow/compute/kernels/scalar_boolean_benchmark.cc
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / arrow / compute / kernels / scalar_boolean_benchmark.cc
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17
18 #include "benchmark/benchmark.h"
19
20 #include <vector>
21
22 #include "arrow/compute/api_scalar.h"
23 #include "arrow/compute/kernels/test_util.h"
24 #include "arrow/testing/gtest_util.h"
25 #include "arrow/testing/random.h"
26 #include "arrow/util/benchmark_util.h"
27
28 namespace arrow {
29 namespace compute {
30
31 constexpr auto kSeed = 0x94378165;
32
33 using BooleanBinaryOp = Result<Datum>(const Datum&, const Datum&, ExecContext*);
34
35 template <BooleanBinaryOp& Op>
36 static void ArrayArrayKernel(benchmark::State& state) {
37 RegressionArgs args(state);
38
39 const int64_t array_size = args.size * 8;
40
41 auto rand = random::RandomArrayGenerator(kSeed);
42 auto lhs = rand.Boolean(array_size, /*true_probability=*/0.5, args.null_proportion);
43 auto rhs = rand.Boolean(array_size, /*true_probability=*/0.5, args.null_proportion);
44
45 for (auto _ : state) {
46 ABORT_NOT_OK(Op(lhs, rhs, nullptr).status());
47 }
48 state.SetItemsProcessed(state.iterations() * array_size);
49 }
50
51 void SetArgs(benchmark::internal::Benchmark* bench) {
52 BenchmarkSetArgsWithSizes(bench, {kL1Size, kL2Size});
53 }
54
55 BENCHMARK_TEMPLATE(ArrayArrayKernel, And)->Apply(SetArgs);
56 BENCHMARK_TEMPLATE(ArrayArrayKernel, KleeneAnd)->Apply(SetArgs);
57
58 } // namespace compute
59 } // namespace arrow