music / rpms / grpc

Forked from rpms/grpc 3 years ago
Clone
d8f3851
From 67cba751363d35fcf88aae7f82616d560d7403fa Mon Sep 17 00:00:00 2001
d8f3851
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
d8f3851
Date: Tue, 14 Sep 2021 15:00:41 -0400
d8f3851
Subject: [PATCH] Adapt to google-benchmark 1.6.0
d8f3851
d8f3851
State::thread_index and State::threads are now accessor methods instead
d8f3851
of data members.
d8f3851
---
d8f3851
 test/cpp/microbenchmarks/bm_cq_multiple_threads.cc | 2 +-
d8f3851
 test/cpp/microbenchmarks/bm_threadpool.cc          | 6 +++---
d8f3851
 2 files changed, 4 insertions(+), 4 deletions(-)
d8f3851
d8f3851
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
d8f3851
index d57a021cee..f9cdd67809 100644
d8f3851
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
d8f3851
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
d8f3851
@@ -160,7 +160,7 @@ static void teardown() {
d8f3851
 */
d8f3851
 static void BM_Cq_Throughput(benchmark::State& state) {
d8f3851
   gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
d8f3851
-  auto thd_idx = state.thread_index;
d8f3851
+  auto thd_idx = state.thread_index();
d8f3851
 
d8f3851
   gpr_mu_lock(&g_mu);
d8f3851
   g_threads_active++;
d8f3851
diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc
d8f3851
index b06deeeb37..cedad52ed2 100644
d8f3851
--- a/test/cpp/microbenchmarks/bm_threadpool.cc
d8f3851
+++ b/test/cpp/microbenchmarks/bm_threadpool.cc
d8f3851
@@ -152,11 +152,11 @@ class SuicideFunctorForAdd : public grpc_completion_queue_functor {
d8f3851
 static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
d8f3851
   static grpc_core::ThreadPool* external_add_pool = nullptr;
d8f3851
   // Setup for each run of test.
d8f3851
-  if (state.thread_index == 0) {
d8f3851
+  if (state.thread_index() == 0) {
d8f3851
     const int num_threads = state.range(1);
d8f3851
     external_add_pool = new grpc_core::ThreadPool(num_threads);
d8f3851
   }
d8f3851
-  const int num_iterations = state.range(0) / state.threads;
d8f3851
+  const int num_iterations = state.range(0) / state.threads();
d8f3851
   while (state.KeepRunningBatch(num_iterations)) {
d8f3851
     BlockingCounter counter(num_iterations);
d8f3851
     for (int i = 0; i < num_iterations; ++i) {
d8f3851
@@ -166,7 +166,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
d8f3851
   }
d8f3851
 
d8f3851
   // Teardown at the end of each test run.
d8f3851
-  if (state.thread_index == 0) {
d8f3851
+  if (state.thread_index() == 0) {
d8f3851
     state.SetItemsProcessed(state.range(0));
d8f3851
     delete external_add_pool;
d8f3851
   }
d8f3851
-- 
d8f3851
2.31.1
d8f3851