aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2016-03-10 23:53:43 -0800
committerGravatar vjpai <vpai@google.com>2016-03-10 23:53:43 -0800
commit2697f2141f8534a80bb4db0d253e3657dfe3eddc (patch)
tree5758b1dd50971d698ddf4fb854d2ee63387f513e /test/cpp
parent32f3ff29d44856b9c8fd24a7bd3b5dc92562aaeb (diff)
parentfbdf51b07e56d0794776e40bc3a4a054e1883f0e (diff)
Merge branch 'master' into debug_qps_stream
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/qps/qps_worker.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index 9442017ddf..b83e9d1dd7 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -101,6 +101,19 @@ static std::unique_ptr<Server> CreateServer(const ServerConfig& config) {
abort();
}
+class ScopedProfile GRPC_FINAL {
+ public:
+ ScopedProfile(const char* filename, bool enable) : enable_(enable) {
+ if (enable_) grpc_profiler_start(filename);
+ }
+ ~ScopedProfile() {
+ if (enable_) grpc_profiler_stop();
+ }
+
+ private:
+ const bool enable_;
+};
+
class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
public:
WorkerServiceImpl(int server_port, QpsWorker* worker)
@@ -114,9 +127,8 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
return Status(StatusCode::RESOURCE_EXHAUSTED, "");
}
- grpc_profiler_start("qps_client.prof");
+ ScopedProfile profile("qps_client.prof", false);
Status ret = RunClientBody(ctx, stream);
- grpc_profiler_stop();
return ret;
}
@@ -128,9 +140,8 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
return Status(StatusCode::RESOURCE_EXHAUSTED, "");
}
- grpc_profiler_start("qps_server.prof");
+ ScopedProfile profile("qps_server.prof", false);
Status ret = RunServerBody(ctx, stream);
- grpc_profiler_stop();
return ret;
}