MCPcopy Create free account
hub / github.com/apache/arrow / IfElseBench

Function IfElseBench

cpp/src/arrow/compute/kernels/scalar_if_else_benchmark.cc:98–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97template <typename Type>
98static void IfElseBench(benchmark::State& state, const std::shared_ptr<DataType>& type) {
99 using ArrayType = typename TypeTraits<Type>::ArrayType;
100
101 int64_t len = state.range(0);
102 int64_t offset = state.range(1);
103
104 random::RandomArrayGenerator rand(/*seed=*/0);
105
106 auto cond = std::static_pointer_cast<BooleanArray>(
107 rand.ArrayOf(boolean(), len, /*null_probability=*/0.01))
108 ->Slice(offset);
109 auto left = std::static_pointer_cast<ArrayType>(
110 rand.ArrayOf(type, len, /*null_probability=*/0.01))
111 ->Slice(offset);
112 auto right = std::static_pointer_cast<ArrayType>(
113 rand.ArrayOf(type, len, /*null_probability=*/0.01))
114 ->Slice(offset);
115
116 for (auto _ : state) {
117 ABORT_NOT_OK(IfElse(cond, left, right));
118 }
119
120 state.SetBytesProcessed(
121 state.iterations() *
122 (GetBytesProcessed(*cond) + GetBytesProcessed(*left) + GetBytesProcessed(*right)));
123 state.SetItemsProcessed(state.iterations() * (len - offset));
124 state.counters["offset"] = static_cast<double>(offset);
125}
126
127template <typename Type>
128static void IfElseBench(benchmark::State& state) {

Callers

nothing calls this directly

Calls 5

IfElseFunction · 0.85
GetBytesProcessedFunction · 0.85
type_singletonFunction · 0.70
SliceMethod · 0.45
ArrayOfMethod · 0.45

Tested by

no test coverage detected