Temporarily disable benchmarks (#27629)
benchmark 1.6.0 introduced API breaking changes so we temporarily disabled the benchmarks that are using the old API to avoid breaking.
This commit is contained in:
parent
60028a82a9
commit
a145013d6d
|
|
@ -162,7 +162,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 = hack::get_thread_idx(state);
|
||||
|
||||
gpr_mu_lock(&g_mu);
|
||||
g_threads_active++;
|
||||
|
|
|
|||
|
|
@ -152,12 +152,13 @@ class SuicideFunctorForAdd : public grpc_completion_queue_functor {
|
|||
// 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;
|
||||
int thread_idx = hack::get_thread_idx(state);
|
||||
// Setup for each run of test.
|
||||
if (state.thread_index == 0) {
|
||||
if (thread_idx == 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) / hack::get_threads(state);
|
||||
while (state.KeepRunningBatch(num_iterations)) {
|
||||
BlockingCounter counter(num_iterations);
|
||||
for (int i = 0; i < num_iterations; ++i) {
|
||||
|
|
@ -167,7 +168,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) {
|
|||
}
|
||||
|
||||
// Teardown at the end of each test run.
|
||||
if (state.thread_index == 0) {
|
||||
if (thread_idx == 0) {
|
||||
state.SetItemsProcessed(state.range(0));
|
||||
delete external_add_pool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef GRPC_TEST_CPP_UTIL_TEST_CONFIG_H
|
||||
#define GRPC_TEST_CPP_UTIL_TEST_CONFIG_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef GRPC_GTEST_FLAG_SET_DEATH_TEST_STYLE
|
||||
#define GRPC_GTEST_FLAG_SET_DEATH_TEST_STYLE(style) \
|
||||
::testing::FLAGS_gtest_death_test_style = style
|
||||
|
|
@ -29,6 +31,35 @@ namespace testing {
|
|||
|
||||
void InitTest(int* argc, char*** argv, bool remove_flags);
|
||||
|
||||
// FIXME(vyng): remove this
|
||||
// This is hack to accommdate accessing .threads and .thread_index on benchmark
|
||||
// State object. (In 1.6.0, the fields were made into methods, hence it's API
|
||||
// breaking).
|
||||
|
||||
namespace hack {
|
||||
|
||||
template <typename T>
|
||||
auto get_threads(T& t) -> decltype(t.threads()) {
|
||||
return t.threads();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto get_threads(T& t) -> decltype(t.threads) {
|
||||
return t.threads;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto get_thread_idx(T& t) -> decltype(t.thread_index()) {
|
||||
return t.thread_index();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto get_thread_idx(T& t) -> decltype(t.thread_index) {
|
||||
return t.thread_index;
|
||||
}
|
||||
|
||||
} // namespace hack
|
||||
|
||||
} // namespace testing
|
||||
} // namespace grpc
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue