aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-03-08 14:12:18 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2016-03-08 14:12:18 -0800
commit81932891af86bb844999dfe1ca70c68ff30c0a5d (patch)
tree63ded1f25ffebab65f58f887baa8b378de515b5f /test/cpp
parent8c3d9943f6061c9c2370ab7e165cb9219adc7a02 (diff)
parent0e67d191267aa9bb641bbeaf11246878c3521e75 (diff)
Merge branch 'master' of github.com:grpc/grpc into codegen_lib
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;
}