From a33e2b27a130d06271d9ed6fa102e9010a1ad1d0 Mon Sep 17 00:00:00 2001
From: Yuxuan Li <yuxuanli@google.com>
Date: Thu, 4 May 2017 16:13:49 -0700
Subject: [PATCH] add some comments

---
 src/proto/grpc/testing/control.proto          |  1 +
 src/proto/grpc/testing/stats.proto            |  2 ++
 test/cpp/microbenchmarks/fullstack_fixtures.h | 32 ++++++-------------
 test/cpp/microbenchmarks/helpers.cc           |  5 ---
 test/cpp/microbenchmarks/helpers.h            |  2 --
 test/cpp/qps/report.h                         |  2 +-
 6 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto
index aa6a23abe5..cb51756bf6 100644
--- a/src/proto/grpc/testing/control.proto
+++ b/src/proto/grpc/testing/control.proto
@@ -242,6 +242,7 @@ message ScenarioResultSummary
   double successful_requests_per_second = 13;
   double failed_requests_per_second = 14;
 
+  // Number of polls called inside completion queue per request
   double client_polls_per_request = 15;
   double server_polls_per_request = 16;
 }
diff --git a/src/proto/grpc/testing/stats.proto b/src/proto/grpc/testing/stats.proto
index 78df533342..e236cf159b 100644
--- a/src/proto/grpc/testing/stats.proto
+++ b/src/proto/grpc/testing/stats.proto
@@ -48,6 +48,7 @@ message ServerStats {
   // change in idle time of the server (data from proc/stat)
   uint64 idle_cpu_time = 5;
 
+  // Number of polls called inside completion queue
   uint64 cq_poll_count = 6;
 }
 
@@ -84,5 +85,6 @@ message ClientStats {
   // Number of failed requests (one row per status code seen)
   repeated RequestResultCount request_results = 5;
 
+  // Number of polls called inside completion queue
   uint64 cq_poll_count = 6;
 }
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index b3ea12cb7a..aa71c2ae3f 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -100,17 +100,10 @@ class FullstackFixture : public BaseFixture {
     }
   }
 
-  void Finish(benchmark::State& state) {
-    std::ostringstream out;
-    AddToLabel(out, state);
-    AppendToLabel(
-        out, "polls/iter",
-        (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations());
-    auto label = out.str();
-    if (label.length() && label[0] == ' ') {
-      label = label.substr(1);
-    }
-    state.SetLabel(label);
+  void AddToLabel(std::ostream& out, benchmark::State& state) {
+    BaseFixture::AddToLabel(out, state);
+    out << " polls/iter:"
+        << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
   }
 
   ServerCompletionQueue* cq() { return cq_.get(); }
@@ -225,17 +218,10 @@ class EndpointPairFixture : public BaseFixture {
     }
   }
 
-  void Finish(benchmark::State& state) {
-    std::ostringstream out;
-    AddToLabel(out, state);
-    AppendToLabel(
-        out, "polls/iter",
-        (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations());
-    auto label = out.str();
-    if (label.length() && label[0] == ' ') {
-      label = label.substr(1);
-    }
-    state.SetLabel(label);
+  void AddToLabel(std::ostream& out, benchmark::State& state) {
+    BaseFixture::AddToLabel(out, state);
+    out << " polls/iter:"
+        << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
   }
 
   ServerCompletionQueue* cq() { return cq_.get(); }
@@ -271,7 +257,7 @@ class InProcessCHTTP2 : public EndpointPairFixture {
   void AddToLabel(std::ostream& out, benchmark::State& state) {
     EndpointPairFixture::AddToLabel(out, state);
     out << " writes/iter:"
-        << ((double)stats_.num_writes / (double)state.iterations());
+        << (double)stats_.num_writes / (double)state.iterations();
   }
 
  private:
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index 76ae055803..6550742453 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -67,8 +67,3 @@ void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
           (double)state.iterations());
 #endif
 }
-
-void TrackCounters::AppendToLabel(std::ostream &out, std::string metric,
-                                  double value) {
-  out << " " << key << ":" << value;
-}
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index 47dda4d4b2..66bf976e3c 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -80,8 +80,6 @@ class TrackCounters {
  public:
   virtual void Finish(benchmark::State& state);
   virtual void AddToLabel(std::ostream& out, benchmark::State& state);
-  virtual void AppendToLabel(std::ostream& out, std::string metric,
-                             double value);
 
  private:
 #ifdef GPR_LOW_LEVEL_COUNTERS
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index 6ed3ea1b0d..621fa7cb00 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -76,7 +76,7 @@ class Reporter {
   /** Reports server cpu usage. */
   virtual void ReportCpuUsage(const ScenarioResult& result) = 0;
 
-  /** Reports server cpu usage. */
+  /** Reports client and server poll usage inside completion queue. */
   virtual void ReportPollCount(const ScenarioResult& result) = 0;
 
  private:
-- 
GitLab