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

Function ThreadedTaskGroup

cpp/src/arrow/util/thread_pool_benchmark.cc:174–199  ·  view source on GitHub ↗

Benchmark threaded TaskGroup

Source from the content-addressed store, hash-verified

172
173// Benchmark threaded TaskGroup
174static void ThreadedTaskGroup(benchmark::State& state) { // NOLINT non-const reference
175 const auto nthreads = static_cast<int>(state.range(0));
176 const auto workload_size = static_cast<int32_t>(state.range(1));
177
178 std::shared_ptr<ThreadPool> pool;
179 pool = *ThreadPool::Make(nthreads);
180
181 Task task(workload_size);
182
183 const int32_t nspawns = 10000000 / workload_size + 1;
184
185 for (auto _ : state) {
186 auto task_group = TaskGroup::MakeThreaded(pool.get());
187 task_group->Append([&task, nspawns, task_group] {
188 for (int32_t i = 0; i < nspawns; ++i) {
189 // Pass the task by reference to avoid copying it around
190 task_group->Append(std::ref(task));
191 }
192 return Status::OK();
193 });
194 ABORT_NOT_OK(task_group->Finish());
195 }
196 ABORT_NOT_OK(pool->Shutdown(true /* wait */));
197
198 state.SetItemsProcessed(state.iterations() * nspawns);
199}
200
201static const std::vector<int32_t> kWorkloadSizes = {1000, 10000, 100000};
202

Callers

nothing calls this directly

Calls 7

refFunction · 0.85
MakeFunction · 0.70
OKFunction · 0.50
getMethod · 0.45
AppendMethod · 0.45
FinishMethod · 0.45
ShutdownMethod · 0.45

Tested by

no test coverage detected