Adapt to google-benchmark 1.6.0

This commit is contained in:
Benjamin A. Beasley 2021-09-14 15:05:01 -04:00
parent c16dbc3a51
commit 987cfed47c
2 changed files with 61 additions and 0 deletions

View File

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

View File

@ -261,6 +261,12 @@ Patch5: grpc-1.37.0-grpc_cli-do-not-link-gtest-gmock.patch
Patch6: grpc-1.39.0-python_wrapper-path.patch
# Port Python 2 scripts used in core tests to Python 3
Patch7: grpc-1.39.0-python2-test-scripts.patch
# Fix compatibility with breaking changes in google-benchmark 1.6.0
#
# This will not be sent upstream since it is impractical to make a patch
# compatible with both 1.6.0 and 1.5.0, and upstream has not yet updated to
# 1.6.0.
Patch8: grpc-1.40.0-google-benchmark-1.6.0.patch
Requires: grpc-data = %{version}-%{release}