Skip to content

Commit

Permalink
Re-format
Browse files Browse the repository at this point in the history
  • Loading branch information
yunjiaw26 committed Jul 19, 2019
1 parent c6bc2b1 commit 85314b3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test/cpp/microbenchmarks/bm_threadpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BlockingCounter {
cv_.wait(l);
}
}

private:
int count_;
std::mutex mu_;
Expand Down Expand Up @@ -153,11 +154,8 @@ static void BM_ThreadPool2048AddAnother(benchmark::State& state) {
}
BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024);



// A functor class that will delete self on end of running.
class SuicideFunctorForAdd
: public grpc_experimental_completion_queue_functor {
class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor {
public:
SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) {
functor_run = &SuicideFunctorForAdd::Run;
Expand All @@ -176,7 +174,6 @@ class SuicideFunctorForAdd
BlockingCounter* counter_;
};


// Performs the scenario of external thread(s) adding closures into pool.
static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
static grpc_core::ThreadPool* external_add_pool = nullptr;
Expand All @@ -185,7 +182,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
const int num_threads = state.range(1);
external_add_pool = new grpc_core::ThreadPool(num_threads);
}
const int num_iterations = state.range(0);
const int num_iterations = state.range(0);
while (state.KeepRunningBatch(num_iterations)) {
BlockingCounter counter(num_iterations);
for (int i = 0; i < num_iterations; ++i) {
Expand Down Expand Up @@ -287,13 +284,14 @@ class ShortWorkFunctorForAdd
val_ = 0;
}
~ShortWorkFunctorForAdd() {}
static void Run(grpc_experimental_completion_queue_functor *cb, int ok) {
static void Run(grpc_experimental_completion_queue_functor* cb, int ok) {
auto* callback = static_cast<ShortWorkFunctorForAdd*>(cb);
for (int i = 0; i < 1000; ++i) {
callback->val_++;
}
callback->counter_->DecrementCount();
}

private:
char pad[ABSL_CACHELINE_SIZE];
volatile int val_;
Expand Down

0 comments on commit 85314b3

Please sign in to comment.