Benchmark serial TaskGroup
| 153 | |
| 154 | // Benchmark serial TaskGroup |
| 155 | static void SerialTaskGroup(benchmark::State& state) { // NOLINT non-const reference |
| 156 | const auto workload_size = static_cast<int32_t>(state.range(0)); |
| 157 | |
| 158 | Task task(workload_size); |
| 159 | |
| 160 | const int32_t nspawns = 10000000 / workload_size + 1; |
| 161 | |
| 162 | for (auto _ : state) { |
| 163 | auto task_group = TaskGroup::MakeSerial(); |
| 164 | for (int32_t i = 0; i < nspawns; ++i) { |
| 165 | // Pass the task by reference to avoid copying it around |
| 166 | task_group->Append(std::ref(task)); |
| 167 | } |
| 168 | ABORT_NOT_OK(task_group->Finish()); |
| 169 | } |
| 170 | state.SetItemsProcessed(state.iterations() * nspawns); |
| 171 | } |
| 172 | |
| 173 | // Benchmark threaded TaskGroup |
| 174 | static void ThreadedTaskGroup(benchmark::State& state) { // NOLINT non-const reference |