diff options
author | Vijay Pai <vpai@google.com> | 2015-02-10 10:39:03 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2015-02-10 10:39:03 -0800 |
commit | c3b02d9a67da11bdeb4eeb5a7986882740dea6d1 (patch) | |
tree | 39c86533669512f2a40696400bf0b682e7dcc0d7 /test | |
parent | 38f9651468b6b72a30c66a5c1309bd225d3ff71a (diff) |
Allow varying number of server threads via command line flag
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/qps/server.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc index c35d9ebdd8..11edfe5824 100644 --- a/test/cpp/qps/server.cc +++ b/test/cpp/qps/server.cc @@ -44,6 +44,7 @@ #include <grpc++/server_builder.h> #include <grpc++/server_context.h> #include <grpc++/status.h> +#include "src/cpp/server/thread_pool.h" #include "test/core/util/grpc_profiler.h" #include "test/cpp/qps/qpstest.pb.h" @@ -52,10 +53,12 @@ DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls."); DEFINE_int32(port, 0, "Server port."); +DEFINE_int32(server_threads, 4, "Number of server threads."); using grpc::Server; using grpc::ServerBuilder; using grpc::ServerContext; +using grpc::ThreadPool; using grpc::testing::Payload; using grpc::testing::PayloadType; using grpc::testing::ServerStats; @@ -126,6 +129,10 @@ static void RunServer() { ServerBuilder builder; builder.AddPort(server_address); builder.RegisterService(service.service()); + + ThreadPool *pool = new ThreadPool(FLAGS_server_threads); + builder.SetThreadPool(pool); + std::unique_ptr<Server> server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s\n", server_address); @@ -137,6 +144,7 @@ static void RunServer() { grpc_profiler_stop(); + delete pool; gpr_free(server_address); } |