aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_cq.cc
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-03-08 14:45:23 -0800
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-03-08 14:45:23 -0800
commit89da88c7b44cb0f1765f6216faf2d5ec3d16f403 (patch)
tree339f51e0ef7d0debaf5dd7e8cc0f1665eca3fbf1 /test/cpp/microbenchmarks/bm_cq.cc
parent36108cce7ddd5c5593b2d36c6105f6a39511b6a2 (diff)
parentc35a5b0e74b036acaf9129118fe449c72bb5f696 (diff)
Merge branch 'master' into cq_create_api_changes
Diffstat (limited to 'test/cpp/microbenchmarks/bm_cq.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index 6fda0081ae..14eae82717 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -38,6 +38,7 @@
#include <grpc++/impl/grpc_library.h>
#include <grpc/grpc.h>
+#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
extern "C" {
@@ -47,30 +48,26 @@ extern "C" {
namespace grpc {
namespace testing {
-static class InitializeStuff {
- public:
- InitializeStuff() { init_lib_.init(); }
- ~InitializeStuff() { init_lib_.shutdown(); }
-
- private:
- internal::GrpcLibrary init_lib_;
- internal::GrpcLibraryInitializer init_;
-} initialize_stuff;
+auto& force_library_initialization = Library::get();
static void BM_CreateDestroyCpp(benchmark::State& state) {
+ TrackCounters track_counters;
while (state.KeepRunning()) {
CompletionQueue cq;
}
+ track_counters.Finish(state);
}
BENCHMARK(BM_CreateDestroyCpp);
static void BM_CreateDestroyCore(benchmark::State& state) {
+ TrackCounters track_counters;
while (state.KeepRunning()) {
- // TODO: sreek Make this a templatized benchmark and pass completion type
- // and polling type as parameters
+ // TODO: sreek Templatize this benchmark and pass completion type and
+ // polling type as parameters
grpc_completion_queue_destroy(grpc_completion_queue_create(
GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL));
}
+ track_counters.Finish(state);
}
BENCHMARK(BM_CreateDestroyCore);
@@ -83,6 +80,7 @@ class DummyTag final : public CompletionQueueTag {
};
static void BM_Pass1Cpp(benchmark::State& state) {
+ TrackCounters track_counters;
CompletionQueue cq;
grpc_completion_queue* c_cq = cq.cq();
while (state.KeepRunning()) {
@@ -97,12 +95,13 @@ static void BM_Pass1Cpp(benchmark::State& state) {
bool ok;
cq.Next(&tag, &ok);
}
+ track_counters.Finish(state);
}
BENCHMARK(BM_Pass1Cpp);
static void BM_Pass1Core(benchmark::State& state) {
- // TODO: sreek Make this templatized benchmark and pass polling_type as a
- // param
+ TrackCounters track_counters;
+ // TODO: sreek Templatize this benchmark and pass polling_type as a param
grpc_completion_queue* cq =
grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL);
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
@@ -116,12 +115,13 @@ static void BM_Pass1Core(benchmark::State& state) {
grpc_completion_queue_next(cq, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
+ track_counters.Finish(state);
}
BENCHMARK(BM_Pass1Core);
static void BM_Pluck1Core(benchmark::State& state) {
- // TODO: sreek Make this templatized benchmark and pass polling_type as a
- // param
+ TrackCounters track_counters;
+ // TODO: sreek Templatize this benchmark and pass polling_type as a param
grpc_completion_queue* cq = grpc_completion_queue_create(
GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL);
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
@@ -135,12 +135,13 @@ static void BM_Pluck1Core(benchmark::State& state) {
grpc_completion_queue_pluck(cq, NULL, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
+ track_counters.Finish(state);
}
BENCHMARK(BM_Pluck1Core);
static void BM_EmptyCore(benchmark::State& state) {
- // TODO: sreek Make this a templatized benchmark and pass polling_type as a
- // param
+ TrackCounters track_counters;
+ // TODO: sreek Templatize this benchmark and pass polling_type as a param
grpc_completion_queue* cq =
grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL);
gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
@@ -148,6 +149,7 @@ static void BM_EmptyCore(benchmark::State& state) {
grpc_completion_queue_next(cq, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
+ track_counters.Finish(state);
}
BENCHMARK(BM_EmptyCore);