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

Function ThreadPoolSpawn

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

Benchmark ThreadPool::Spawn

Source from the content-addressed store, hash-verified

75
76// Benchmark ThreadPool::Spawn
77static void ThreadPoolSpawn(benchmark::State& state) { // NOLINT non-const reference
78 const auto nthreads = static_cast<int>(state.range(0));
79 const auto workload_size = static_cast<int32_t>(state.range(1));
80
81 Workload workload(workload_size);
82
83 // Spawn enough tasks to make the pool start up overhead negligible
84 const int32_t nspawns = 200000000 / workload_size + 1;
85
86 for (auto _ : state) {
87 state.PauseTiming();
88 std::shared_ptr<ThreadPool> pool;
89 pool = *ThreadPool::Make(nthreads);
90 state.ResumeTiming();
91
92 for (int32_t i = 0; i < nspawns; ++i) {
93 // Pass the task by reference to avoid copying it around
94 ABORT_NOT_OK(pool->Spawn(std::ref(workload)));
95 }
96
97 // Wait for all tasks to finish
98 ABORT_NOT_OK(pool->Shutdown(true /* wait */));
99 state.PauseTiming();
100 pool.reset();
101 state.ResumeTiming();
102 }
103 state.SetItemsProcessed(state.iterations() * nspawns);
104}
105
106// Benchmark SerialExecutor::RunInSerialExecutor
107static void RunInSerialExecutor(benchmark::State& state) { // NOLINT non-const reference

Callers

nothing calls this directly

Calls 4

refFunction · 0.85
MakeFunction · 0.70
ShutdownMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected