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

Function BenchmarkAggregate

cpp/src/arrow/acero/aggregate_benchmark.cc:377–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377static void BenchmarkAggregate(
378 benchmark::State& state, std::vector<Aggregate> aggregates,
379 const std::vector<std::shared_ptr<Array>>& arguments,
380 const std::vector<std::shared_ptr<Array>>& keys,
381 const std::vector<std::shared_ptr<Array>>& segment_keys = {}) {
382 std::shared_ptr<RecordBatch> batch =
383 RecordBatchFromArrays(arguments, keys, segment_keys);
384 std::vector<FieldRef> key_refs;
385 for (std::size_t key_idx = 0; key_idx < keys.size(); key_idx++) {
386 key_refs.emplace_back(static_cast<int>(key_idx + arguments.size()));
387 }
388 std::vector<FieldRef> segment_key_refs;
389 for (std::size_t segment_key_idx = 0; segment_key_idx < segment_keys.size();
390 segment_key_idx++) {
391 segment_key_refs.emplace_back(
392 static_cast<int>(segment_key_idx + arguments.size() + keys.size()));
393 }
394 for (std::size_t arg_idx = 0; arg_idx < arguments.size(); arg_idx++) {
395 aggregates[arg_idx].target = {FieldRef(static_cast<int>(arg_idx))};
396 }
397 int64_t total_bytes = TotalBufferSize(*batch);
398 for (auto _ : state) {
399 ABORT_NOT_OK(BatchGroupBy(batch, aggregates, key_refs, segment_key_refs));
400 }
401 state.SetBytesProcessed(total_bytes * state.iterations());
402 state.SetItemsProcessed(batch->num_rows() * state.iterations());
403}
404
405#define GROUP_BY_BENCHMARK(Name, Impl) \
406 static void Name(benchmark::State& state) { \

Callers 2

Calls 7

RecordBatchFromArraysFunction · 0.85
TotalBufferSizeFunction · 0.85
BatchGroupByFunction · 0.85
emplace_backMethod · 0.80
FieldRefFunction · 0.50
sizeMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected