MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / BM_BlockingCounter

Function BM_BlockingCounter

tensorflow/core/lib/core/blocking_counter_test.cc:52–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50} // namespace
51
52static void BM_BlockingCounter(int iters, int num_threads,
53 int shards_per_thread) {
54 testing::StopTiming();
55 std::unique_ptr<thread::ThreadPool> thread_pool(
56 new thread::ThreadPool(Env::Default(), "test", num_threads));
57 const int num_shards = num_threads * shards_per_thread;
58 testing::StartTiming();
59 for (int i = 0; i < iters; ++i) {
60 BlockingCounter bc(num_shards);
61 for (int j = 0; j < num_threads; ++j) {
62 thread_pool->Schedule([&bc, shards_per_thread] {
63 for (int k = 0; k < shards_per_thread; ++k) {
64 bc.DecrementCount();
65 }
66 });
67 }
68 bc.Wait();
69 }
70 testing::StopTiming();
71}
72
73BENCHMARK(BM_BlockingCounter)->RangePair(1, 12, 1, 1000);
74

Callers

nothing calls this directly

Calls 6

StopTimingFunction · 0.85
DefaultFunction · 0.85
StartTimingFunction · 0.85
ScheduleMethod · 0.45
DecrementCountMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected