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

Function BenchmarkFieldPathGet

cpp/src/arrow/type_benchmark.cc:477–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475
476template <typename T>
477static void BenchmarkFieldPathGet(benchmark::State& state, // NOLINT non-const reference
478 const T& input, int num_columns,
479 std::optional<int> num_chunks = {}) {
480 // Reassigning a single FieldPath var within each iteration's scope seems to be costly
481 // enough to influence the timings, so we preprocess them.
482 std::vector<FieldPath> paths(num_columns);
483 for (int i = 0; i < num_columns; ++i) {
484 paths[i] = {i};
485 }
486
487 for (auto _ : state) {
488 for (const auto& path : paths) {
489 benchmark::DoNotOptimize(path.Get(input).ValueOrDie());
490 }
491 }
492
493 state.SetItemsProcessed(state.iterations() * num_columns);
494 state.counters["num_columns"] = num_columns;
495 if (num_chunks.has_value()) {
496 state.counters["num_chunks"] = num_chunks.value();
497 }
498}
499
500static void FieldPathGetFromWideArray(
501 benchmark::State& state) { // NOLINT non-const reference

Calls 3

ValueOrDieMethod · 0.80
GetMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected