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

Function BenchmarkFieldPathGet

cpp/src/arrow/type_benchmark.cc:491–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489
490template <typename T>
491static void BenchmarkFieldPathGet(benchmark::State& state, // NOLINT non-const reference
492 const T& input, int num_columns,
493 std::optional<int> num_chunks = {}) {
494 // Reassigning a single FieldPath var within each iteration's scope seems to be costly
495 // enough to influence the timings, so we preprocess them.
496 std::vector<FieldPath> paths(num_columns);
497 for (int i = 0; i < num_columns; ++i) {
498 paths[i] = {i};
499 }
500
501 for (auto _ : state) {
502 for (const auto& path : paths) {
503 benchmark::DoNotOptimize(path.Get(input).ValueOrDie());
504 }
505 }
506
507 state.SetItemsProcessed(state.iterations() * num_columns);
508 state.counters["num_columns"] = num_columns;
509 if (num_chunks.has_value()) {
510 state.counters["num_chunks"] = num_chunks.value();
511 }
512}
513
514static void FieldPathGetFromWideArray(
515 benchmark::State& state) { // NOLINT non-const reference

Calls 3

ValueOrDieMethod · 0.80
GetMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected