]>
git.proxmox.com Git - ceph.git/blob - 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
9 // http://www.apache.org/licenses/LICENSE-2.0
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
18 #include "benchmark/benchmark.h"
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"
31 constexpr auto kSeed
= 0x94378165;
33 using BooleanBinaryOp
= Result
<Datum
>(const Datum
&, const Datum
&, ExecContext
*);
35 template <BooleanBinaryOp
& Op
>
36 static void ArrayArrayKernel(benchmark::State
& state
) {
37 RegressionArgs
args(state
);
39 const int64_t array_size
= args
.size
* 8;
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
);
45 for (auto _
: state
) {
46 ABORT_NOT_OK(Op(lhs
, rhs
, nullptr).status());
48 state
.SetItemsProcessed(state
.iterations() * array_size
);
51 void SetArgs(benchmark::internal::Benchmark
* bench
) {
52 BenchmarkSetArgsWithSizes(bench
, {kL1Size
, kL2Size
});
55 BENCHMARK_TEMPLATE(ArrayArrayKernel
, And
)->Apply(SetArgs
);
56 BENCHMARK_TEMPLATE(ArrayArrayKernel
, KleeneAnd
)->Apply(SetArgs
);
58 } // namespace compute