| 489 | |
| 490 | template <typename T> |
| 491 | static 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 | |
| 514 | static void FieldPathGetFromWideArray( |
| 515 | benchmark::State& state) { // NOLINT non-const reference |
no test coverage detected