| 50 | } // namespace |
| 51 | |
| 52 | static 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 | |
| 73 | BENCHMARK(BM_BlockingCounter)->RangePair(1, 12, 1, 1000); |
| 74 |
nothing calls this directly
no test coverage detected