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

Class TakeBenchmark

cpp/src/arrow/compute/kernels/vector_selection_benchmark.cc:111–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109};
110
111struct TakeBenchmark {
112 benchmark::State& state;
113 RegressionArgs args;
114 random::RandomArrayGenerator rand;
115 double selection_factor;
116 bool indices_have_nulls;
117 bool monotonic_indices = false;
118
119 TakeBenchmark(benchmark::State& state, bool indices_have_nulls,
120 bool monotonic_indices = false)
121 : TakeBenchmark(state, /*selection_factor=*/kDefaultTakeSelectionFactor,
122 indices_have_nulls, monotonic_indices) {}
123
124 TakeBenchmark(benchmark::State& state, double selection_factor, bool indices_have_nulls,
125 bool monotonic_indices = false)
126 : state(state),
127 args(state, /*size_is_bytes=*/false),
128 rand(kSeed),
129 selection_factor(selection_factor),
130 indices_have_nulls(indices_have_nulls),
131 monotonic_indices(monotonic_indices) {}
132
133 static constexpr int kStringMinLength = 0;
134 static constexpr int kStringMaxLength = 32;
135 static constexpr int kByteWidthRange = 2;
136
137 template <typename GenChunk>
138 std::shared_ptr<ChunkedArray> GenChunkedArray(int64_t num_chunks,
139 GenChunk&& gen_chunk) {
140 const int64_t chunk_length =
141 std::llround(args.size / static_cast<double>(num_chunks));
142 ArrayVector chunks;
143 for (int64_t i = 0; i < num_chunks; ++i) {
144 const int64_t fitting_chunk_length =
145 std::min(chunk_length, args.size - i * chunk_length);
146 chunks.push_back(gen_chunk(fitting_chunk_length));
147 }
148 return std::make_shared<ChunkedArray>(std::move(chunks));
149 }
150
151 void Int64() {
152 auto values = rand.Int64(args.size, -100, 100, args.null_proportion);
153 Bench(values);
154 }
155
156 void FSLInt64() {
157 auto int_array = rand.Int64(args.size, -100, 100, args.null_proportion);
158 auto values = std::make_shared<FixedSizeListArray>(
159 fixed_size_list(int64(), 1), args.size, int_array, int_array->null_bitmap(),
160 int_array->null_count());
161 Bench(values);
162 }
163
164 void FixedSizeBinary() {
165 const auto byte_width = static_cast<int32_t>(state.range(kByteWidthRange));
166 auto values = rand.FixedSizeBinary(args.size, byte_width, args.null_proportion);
167 Bench(values);
168 state.counters["byte_width"] = byte_width;

Calls

no outgoing calls

Tested by

no test coverage detected