diff options
author | 2015-03-04 12:50:11 -0800 | |
---|---|---|
committer | 2015-03-04 12:50:11 -0800 | |
commit | d6479d6cc42ca180bcfc219751cf2a6f73f87dd4 (patch) | |
tree | 2ffe4636168ac687015b8ca2b47181501549f744 /test/cpp/qps/server.h | |
parent | ef6383904280e5606cbf6b5f71a534b1da17e956 (diff) |
Async server works
Diffstat (limited to 'test/cpp/qps/server.h')
-rw-r--r-- | test/cpp/qps/server.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 3542c17a6a..ca22d7ca1c 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -34,6 +34,7 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H +#include "test/cpp/qps/timer.h" #include "test/cpp/qps/qpstest.pb.h" namespace grpc { @@ -41,9 +42,36 @@ namespace testing { class Server { public: + Server():timer_(new Timer) {} virtual ~Server() {} - virtual ServerStats Mark() = 0; + ServerStats Mark() { + std::unique_ptr<Timer> timer(new Timer); + timer.swap(timer_); + + auto timer_result = timer->Mark(); + + ServerStats stats; + stats.set_time_elapsed(timer_result.wall); + stats.set_time_system(timer_result.system); + stats.set_time_user(timer_result.user); + return stats; + } + + static bool SetPayload(PayloadType type, int size, Payload* payload) { + PayloadType response_type = type; + // TODO(yangg): Support UNCOMPRESSABLE payload. + if (type != PayloadType::COMPRESSABLE) { + return false; + } + payload->set_type(response_type); + std::unique_ptr<char[]> body(new char[size]()); + payload->set_body(body.get(), size); + return true; + } + + private: + std::unique_ptr<Timer> timer_; }; std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config, |