diff options
author | Vijay Pai <vpai@google.com> | 2016-02-01 16:40:06 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2016-02-01 16:40:06 -0800 |
commit | 33e51184fcb4bb021a6b2878d90a2d19c53821ff (patch) | |
tree | 74704fdd20a9bf68cc2d0c3fc9a029e711d3a102 /test/cpp/qps | |
parent | 0d7a070e7e51f87bbcdaf72b5a25d0430f82093b (diff) |
Address reviewer comments regarding const and shortage of comments
Diffstat (limited to 'test/cpp/qps')
-rw-r--r-- | test/cpp/qps/driver.cc | 10 | ||||
-rw-r--r-- | test/cpp/qps/limit_cores.cc | 4 | ||||
-rw-r--r-- | test/cpp/qps/limit_cores.h | 9 |
3 files changed, 13 insertions, 10 deletions
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 57b85b107f..9eef4076d9 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -65,7 +65,7 @@ static std::string get_host(const std::string& worker) { char* port; gpr_split_host_port(worker.c_str(), &host, &port); - string s(host); + const string s(host); gpr_free(host); gpr_free(port); @@ -76,7 +76,7 @@ static std::unordered_map<string, std::deque<int>> get_hosts_and_cores( const deque<string>& workers) { std::unordered_map<string, std::deque<int>> hosts; for (auto it = workers.begin(); it != workers.end(); it++) { - string host = get_host(*it); + const string host = get_host(*it); if (hosts.find(host) == hosts.end()) { auto stub = WorkerService::NewStub( CreateChannel(*it, InsecureChannelCredentials())); @@ -149,7 +149,7 @@ std::unique_ptr<ScenarioResult> RunScenario( // To be added to the result, containing the final configuration used for // client and config (including host, etc.) ClientConfig result_client_config; - ServerConfig result_server_config = initial_server_config; + const ServerConfig result_server_config = initial_server_config; // Get client, server lists auto workers = get_workers("QPS_WORKERS"); @@ -224,7 +224,7 @@ std::unique_ptr<ScenarioResult> RunScenario( if (server_core_limit == 0 && client_core_limit > 0) { // In this case, limit the server cores if it matches the // same host as one or more clients - const auto& dq = hosts_cores[host_str]; + const auto& dq = hosts_cores.at(host_str); bool match = false; int limit = dq.size(); for (size_t cli = 0; cli < num_clients; cli++) { @@ -239,7 +239,7 @@ std::unique_ptr<ScenarioResult> RunScenario( } } if (server_core_limit > 0) { - auto& dq = hosts_cores[host_str]; + auto& dq = hosts_cores.at(host_str); GPR_ASSERT(dq.size() >= static_cast<size_t>(server_core_limit)); for (int core = 0; core < server_core_limit; core++) { server_config.add_core_list(dq.front()); diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/qps/limit_cores.cc index 5fd8d555a5..c2f3ad8fde 100644 --- a/test/cpp/qps/limit_cores.cc +++ b/test/cpp/qps/limit_cores.cc @@ -47,12 +47,12 @@ namespace testing { #endif #include <sched.h> int LimitCores(const int *cores, int cores_size) { - int num_cores = gpr_cpu_num_cores(); + const int num_cores = gpr_cpu_num_cores(); int cores_set = 0; cpu_set_t *cpup = CPU_ALLOC(num_cores); GPR_ASSERT(cpup); - size_t size = CPU_ALLOC_SIZE(num_cores); + const size_t size = CPU_ALLOC_SIZE(num_cores); CPU_ZERO_S(size, cpup); if (cores_size > 0) { diff --git a/test/cpp/qps/limit_cores.h b/test/cpp/qps/limit_cores.h index 5467f3b881..5c0d1e315d 100644 --- a/test/cpp/qps/limit_cores.h +++ b/test/cpp/qps/limit_cores.h @@ -38,9 +38,12 @@ namespace grpc { namespace testing { -// LimitCores takes array and size arguments (instead of vector) for more direct -// conversion from repeated field of protobuf. Use a cores_size of 0 to remove -// existing limits (from an empty repeated field) +/// LimitCores: allow this worker to only run on the cores specified in the +/// array \a cores, which is of length \a cores_size. +/// +/// LimitCores takes array and size arguments (instead of vector) for direct +/// conversion from repeated field of protobuf. Use a cores_size of 0 to remove +/// existing limits (from an empty repeated field) int LimitCores(const int *cores, int cores_size); } // namespace testing } // namespace grpc |