MCPcopy Create free account
hub / github.com/UbiquitousLearning/mllm / BM_SharedPtr_Multithreaded

Function BM_SharedPtr_Multithreaded

benchmarks/ext_stl/intrusive_ptr.cpp:192–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 ->Args({8, 10000});
191
192static void BM_SharedPtr_Multithreaded(benchmark::State& state) {
193 const int thread_count = state.range(0);
194 const int ops_per_thread = state.range(1);
195
196 for (auto _ : state) {
197 std::shared_ptr<TestObjectShared> original = std::make_shared<TestObjectShared>(42);
198 std::vector<std::thread> threads;
199 std::vector<std::shared_ptr<TestObjectShared>> local_ptrs(thread_count * ops_per_thread);
200
201 for (int t = 0; t < thread_count; ++t) {
202 threads.emplace_back([&, t]() { // NOLINT
203 for (int i = 0; i < ops_per_thread; ++i) {
204 local_ptrs[t * ops_per_thread + i] = original;
205 local_ptrs[t * ops_per_thread + i]->doWork();
206 }
207 });
208 }
209
210 for (auto& t : threads) { t.join(); }
211
212 benchmark::ClobberMemory();
213 }
214 state.SetItemsProcessed(state.iterations() * thread_count * ops_per_thread);
215}
216BENCHMARK(BM_SharedPtr_Multithreaded)
217 ->Args({2, 1000})
218 ->Args({4, 1000})

Callers

nothing calls this directly

Calls 1

doWorkMethod · 0.45

Tested by

no test coverage detected