| 96 | |
| 97 | template <typename Type> |
| 98 | static 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 | |
| 127 | template <typename Type> |
| 128 | static void IfElseBench(benchmark::State& state) { |
nothing calls this directly
no test coverage detected