pull/19695/head
Yunjia Wang 5 years ago
parent c6bc2b1875
commit 85314b3fcc
  1. 8
      test/cpp/microbenchmarks/bm_threadpool.cc

@ -49,6 +49,7 @@ class BlockingCounter {
cv_.wait(l); cv_.wait(l);
} }
} }
private: private:
int count_; int count_;
std::mutex mu_; std::mutex mu_;
@ -153,11 +154,8 @@ static void BM_ThreadPool2048AddAnother(benchmark::State& state) {
} }
BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024); BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024);
// A functor class that will delete self on end of running. // A functor class that will delete self on end of running.
class SuicideFunctorForAdd class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor {
: public grpc_experimental_completion_queue_functor {
public: public:
SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) { SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) {
functor_run = &SuicideFunctorForAdd::Run; functor_run = &SuicideFunctorForAdd::Run;
@ -176,7 +174,6 @@ class SuicideFunctorForAdd
BlockingCounter* counter_; BlockingCounter* counter_;
}; };
// Performs the scenario of external thread(s) adding closures into pool. // Performs the scenario of external thread(s) adding closures into pool.
static void BM_ThreadPoolExternalAdd(benchmark::State& state) { static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
static grpc_core::ThreadPool* external_add_pool = nullptr; static grpc_core::ThreadPool* external_add_pool = nullptr;
@ -294,6 +291,7 @@ class ShortWorkFunctorForAdd
} }
callback->counter_->DecrementCount(); callback->counter_->DecrementCount();
} }
private: private:
char pad[ABSL_CACHELINE_SIZE]; char pad[ABSL_CACHELINE_SIZE];
volatile int val_; volatile int val_;

Loading…
Cancel
Save