| 475 | |
| 476 | template <typename T> |
| 477 | static 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 | |
| 500 | static void FieldPathGetFromWideArray( |
| 501 | benchmark::State& state) { // NOLINT non-const reference |
no test coverage detected