aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/server.h
diff options
context:
space:
mode:
authorGravatar Yuxuan Li <yuxuanli@google.com>2017-05-03 22:27:11 -0700
committerGravatar Yuxuan Li <yuxuanli@google.com>2017-05-03 22:27:11 -0700
commit5d3ddeeea1dc88392cfb126ebd5b86185c2d36cc (patch)
tree7794086c5a4a7c06a4fdfacb437af50da60add4c /test/cpp/qps/server.h
parent999ac157e648d6bccdec16a696842bdbf5416e27 (diff)
adding server side poll stat
Diffstat (limited to 'test/cpp/qps/server.h')
-rw-r--r--test/cpp/qps/server.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 8fbf37a095..5d5d5ffe09 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -49,7 +49,7 @@ namespace testing {
class Server {
public:
- explicit Server(const ServerConfig& config) : timer_(new UsageTimer) {
+ explicit Server(const ServerConfig& config) : timer_(new UsageTimer), last_reset_poll_count_(0) {
cores_ = gpr_cpu_num_cores();
if (config.port()) {
port_ = config.port();
@@ -62,10 +62,12 @@ class Server {
ServerStats Mark(bool reset) {
UsageTimer::Result timer_result;
+ int last_reset_poll_count_to_use = last_reset_poll_count_;
if (reset) {
std::unique_ptr<UsageTimer> timer(new UsageTimer);
timer.swap(timer_);
timer_result = timer->Mark();
+ last_reset_poll_count_ = GetPollCount();
} else {
timer_result = timer_->Mark();
}
@@ -76,6 +78,7 @@ class Server {
stats.set_time_user(timer_result.user);
stats.set_total_cpu_time(timer_result.total_cpu_time);
stats.set_idle_cpu_time(timer_result.idle_cpu_time);
+ stats.set_cq_poll_count(GetPollCount() - last_reset_poll_count_to_use);
return stats;
}
@@ -106,10 +109,16 @@ class Server {
}
}
+ virtual int GetPollCount() {
+ // For sync server.
+ return 0;
+ }
+
private:
int port_;
int cores_;
std::unique_ptr<UsageTimer> timer_;
+ int last_reset_poll_count_;
};
std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config);