Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2015, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame^] | 34 | #include <unistd.h> |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 35 | #include <list> |
| 36 | #include <thread> |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 37 | #include <deque> |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 38 | #include <vector> |
yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame^] | 39 | |
| 40 | #include <grpc/support/alloc.h> |
| 41 | #include <grpc/support/log.h> |
| 42 | #include <grpc/support/host_port.h> |
| 43 | #include <grpc++/client_context.h> |
| 44 | #include <grpc++/create_channel.h> |
| 45 | |
| 46 | #include "src/core/support/env.h" |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 47 | #include "test/core/util/port.h" |
Craig Tiller | 882431f | 2015-05-19 09:25:37 -0700 | [diff] [blame] | 48 | #include "test/core/util/test_config.h" |
yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame^] | 49 | #include "test/cpp/qps/driver.h" |
| 50 | #include "test/cpp/qps/histogram.h" |
| 51 | #include "test/cpp/qps/qps_worker.h" |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 52 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 53 | using std::list; |
| 54 | using std::thread; |
| 55 | using std::unique_ptr; |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 56 | using std::deque; |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 57 | using std::vector; |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 58 | |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 59 | namespace grpc { |
| 60 | namespace testing { |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 61 | static deque<string> get_hosts(const string& name) { |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 62 | char* env = gpr_getenv(name.c_str()); |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 63 | if (!env) return deque<string>(); |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 64 | |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 65 | deque<string> out; |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 66 | char* p = env; |
| 67 | for (;;) { |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 68 | char* comma = strchr(p, ','); |
| 69 | if (comma) { |
| 70 | out.emplace_back(p, comma); |
| 71 | p = comma + 1; |
| 72 | } else { |
| 73 | out.emplace_back(p); |
| 74 | gpr_free(env); |
| 75 | return out; |
| 76 | } |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 80 | // Namespace for classes and functions used only in RunScenario |
| 81 | // Using this rather than local definitions to workaround gcc-4.4 limitations |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 82 | // regarding using templates without linkage |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 83 | namespace runsc { |
| 84 | |
| 85 | // ClientContext allocator |
| 86 | static ClientContext* AllocContext(list<ClientContext>* contexts) { |
| 87 | contexts->emplace_back(); |
| 88 | return &contexts->back(); |
| 89 | } |
| 90 | |
| 91 | struct ServerData { |
| 92 | unique_ptr<Worker::Stub> stub; |
| 93 | unique_ptr<ClientReaderWriter<ServerArgs, ServerStatus>> stream; |
| 94 | }; |
| 95 | |
| 96 | struct ClientData { |
| 97 | unique_ptr<Worker::Stub> stub; |
| 98 | unique_ptr<ClientReaderWriter<ClientArgs, ClientStatus>> stream; |
| 99 | }; |
Vijay Pai | 3ae1104 | 2015-08-11 22:43:14 -0700 | [diff] [blame] | 100 | } // namespace runsc |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 101 | |
David Garcia Quintas | 0811650 | 2015-05-20 17:27:23 -0700 | [diff] [blame] | 102 | std::unique_ptr<ScenarioResult> RunScenario( |
| 103 | const ClientConfig& initial_client_config, size_t num_clients, |
| 104 | const ServerConfig& server_config, size_t num_servers, int warmup_seconds, |
| 105 | int benchmark_seconds, int spawn_local_worker_count) { |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 106 | // ClientContext allocations (all are destroyed at scope exit) |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 107 | list<ClientContext> contexts; |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 108 | |
David Garcia Quintas | 6ba29ba | 2015-05-19 18:29:35 -0700 | [diff] [blame] | 109 | // To be added to the result, containing the final configuration used for |
| 110 | // client and config (incluiding host, etc.) |
| 111 | ClientConfig result_client_config; |
| 112 | ServerConfig result_server_config; |
| 113 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 114 | // Get client, server lists |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 115 | auto workers = get_hosts("QPS_WORKERS"); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 116 | ClientConfig client_config = initial_client_config; |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 117 | |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 118 | // Spawn some local workers if desired |
| 119 | vector<unique_ptr<QpsWorker>> local_workers; |
| 120 | for (int i = 0; i < abs(spawn_local_worker_count); i++) { |
Craig Tiller | 49c3b01 | 2015-05-19 08:18:02 -0700 | [diff] [blame] | 121 | // act as if we're a new test -- gets a good rng seed |
| 122 | static bool called_init = false; |
| 123 | if (!called_init) { |
Craig Tiller | 882431f | 2015-05-19 09:25:37 -0700 | [diff] [blame] | 124 | char args_buf[100]; |
| 125 | strcpy(args_buf, "some-benchmark"); |
Craig Tiller | 5c8737d | 2015-05-21 11:42:17 -0700 | [diff] [blame] | 126 | char* args[] = {args_buf}; |
Craig Tiller | 49c3b01 | 2015-05-19 08:18:02 -0700 | [diff] [blame] | 127 | grpc_test_init(1, args); |
| 128 | called_init = true; |
| 129 | } |
| 130 | |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 131 | int driver_port = grpc_pick_unused_port_or_die(); |
| 132 | int benchmark_port = grpc_pick_unused_port_or_die(); |
| 133 | local_workers.emplace_back(new QpsWorker(driver_port, benchmark_port)); |
| 134 | char addr[256]; |
| 135 | sprintf(addr, "localhost:%d", driver_port); |
| 136 | if (spawn_local_worker_count < 0) { |
| 137 | workers.push_front(addr); |
| 138 | } else { |
| 139 | workers.push_back(addr); |
| 140 | } |
| 141 | } |
| 142 | |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame] | 143 | // TODO(ctiller): support running multiple configurations, and binpack |
| 144 | // client/server pairs |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 145 | // to available workers |
| 146 | GPR_ASSERT(workers.size() >= num_clients + num_servers); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 147 | |
| 148 | // Trim to just what we need |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 149 | workers.resize(num_clients + num_servers); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 150 | |
| 151 | // Start servers |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 152 | using runsc::ServerData; |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 153 | // servers is array rather than std::vector to avoid gcc-4.4 issues |
| 154 | // where class contained in std::vector must have a copy constructor |
vjpai | b1db869 | 2015-08-11 22:41:02 -0700 | [diff] [blame] | 155 | auto* servers = new ServerData[num_servers]; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 156 | for (size_t i = 0; i < num_servers; i++) { |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 157 | servers[i].stub = std::move(Worker::NewStub( |
Craig Tiller | 68de8e9 | 2015-03-05 15:45:46 -0800 | [diff] [blame] | 158 | CreateChannel(workers[i], InsecureCredentials(), ChannelArguments()))); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 159 | ServerArgs args; |
David Garcia Quintas | 6ba29ba | 2015-05-19 18:29:35 -0700 | [diff] [blame] | 160 | result_server_config = server_config; |
| 161 | result_server_config.set_host(workers[i]); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 162 | *args.mutable_setup() = server_config; |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 163 | servers[i].stream = |
| 164 | std::move(servers[i].stub->RunServer(runsc::AllocContext(&contexts))); |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 165 | GPR_ASSERT(servers[i].stream->Write(args)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 166 | ServerStatus init_status; |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 167 | GPR_ASSERT(servers[i].stream->Read(&init_status)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 168 | char* host; |
| 169 | char* driver_port; |
| 170 | char* cli_target; |
| 171 | gpr_split_host_port(workers[i].c_str(), &host, &driver_port); |
| 172 | gpr_join_host_port(&cli_target, host, init_status.port()); |
| 173 | client_config.add_server_targets(cli_target); |
| 174 | gpr_free(host); |
| 175 | gpr_free(driver_port); |
| 176 | gpr_free(cli_target); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | // Start clients |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 180 | using runsc::ClientData; |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 181 | // clients is array rather than std::vector to avoid gcc-4.4 issues |
| 182 | // where class contained in std::vector must have a copy constructor |
vjpai | b1db869 | 2015-08-11 22:41:02 -0700 | [diff] [blame] | 183 | auto* clients = new ClientData[num_clients]; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 184 | for (size_t i = 0; i < num_clients; i++) { |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 185 | clients[i].stub = std::move(Worker::NewStub(CreateChannel( |
Craig Tiller | 68de8e9 | 2015-03-05 15:45:46 -0800 | [diff] [blame] | 186 | workers[i + num_servers], InsecureCredentials(), ChannelArguments()))); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 187 | ClientArgs args; |
David Garcia Quintas | 6ba29ba | 2015-05-19 18:29:35 -0700 | [diff] [blame] | 188 | result_client_config = client_config; |
| 189 | result_client_config.set_host(workers[i + num_servers]); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 190 | *args.mutable_setup() = client_config; |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 191 | clients[i].stream = |
| 192 | std::move(clients[i].stub->RunTest(runsc::AllocContext(&contexts))); |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 193 | GPR_ASSERT(clients[i].stream->Write(args)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 194 | ClientStatus init_status; |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 195 | GPR_ASSERT(clients[i].stream->Read(&init_status)); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 196 | } |
| 197 | |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 198 | // Let everything warmup |
| 199 | gpr_log(GPR_INFO, "Warming up"); |
Craig Tiller | 20b5fe9 | 2015-07-06 10:43:50 -0700 | [diff] [blame] | 200 | gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); |
Craig Tiller | 677c50c | 2015-07-13 10:49:06 -0700 | [diff] [blame] | 201 | gpr_sleep_until( |
| 202 | gpr_time_add(start, gpr_time_from_seconds(warmup_seconds, GPR_TIMESPAN))); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 203 | |
| 204 | // Start a run |
| 205 | gpr_log(GPR_INFO, "Starting"); |
| 206 | ServerArgs server_mark; |
| 207 | server_mark.mutable_mark(); |
| 208 | ClientArgs client_mark; |
| 209 | client_mark.mutable_mark(); |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 210 | for (auto server = &servers[0]; server != &servers[num_servers]; server++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 211 | GPR_ASSERT(server->stream->Write(server_mark)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 212 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 213 | for (auto client = &clients[0]; client != &clients[num_clients]; client++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 214 | GPR_ASSERT(client->stream->Write(client_mark)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 215 | } |
| 216 | ServerStatus server_status; |
| 217 | ClientStatus client_status; |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 218 | for (auto server = &servers[0]; server != &servers[num_servers]; server++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 219 | GPR_ASSERT(server->stream->Read(&server_status)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 220 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 221 | for (auto client = &clients[0]; client != &clients[num_clients]; client++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 222 | GPR_ASSERT(client->stream->Read(&client_status)); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 223 | } |
| 224 | |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 225 | // Wait some time |
| 226 | gpr_log(GPR_INFO, "Running"); |
Vijay Pai | 90e7369 | 2015-08-05 19:15:36 -0700 | [diff] [blame] | 227 | // Use gpr_sleep_until rather than this_thread::sleep_until to support |
| 228 | // compilers that don't work with this_thread |
Craig Tiller | 677c50c | 2015-07-13 10:49:06 -0700 | [diff] [blame] | 229 | gpr_sleep_until(gpr_time_add( |
| 230 | start, gpr_time_from_seconds(benchmark_seconds, GPR_TIMESPAN))); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 231 | |
| 232 | // Finish a run |
David Garcia Quintas | 0811650 | 2015-05-20 17:27:23 -0700 | [diff] [blame] | 233 | std::unique_ptr<ScenarioResult> result(new ScenarioResult); |
| 234 | result->client_config = result_client_config; |
| 235 | result->server_config = result_server_config; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 236 | gpr_log(GPR_INFO, "Finishing"); |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 237 | for (auto server = &servers[0]; server != &servers[num_servers]; server++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 238 | GPR_ASSERT(server->stream->Write(server_mark)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 239 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 240 | for (auto client = &clients[0]; client != &clients[num_clients]; client++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 241 | GPR_ASSERT(client->stream->Write(client_mark)); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 242 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 243 | for (auto server = &servers[0]; server != &servers[num_servers]; server++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 244 | GPR_ASSERT(server->stream->Read(&server_status)); |
Craig Tiller | f282514 | 2015-03-03 17:15:36 -0800 | [diff] [blame] | 245 | const auto& stats = server_status.stats(); |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 246 | result->server_resources.emplace_back( |
| 247 | stats.time_elapsed(), stats.time_user(), stats.time_system()); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 248 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 249 | for (auto client = &clients[0]; client != &clients[num_clients]; client++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 250 | GPR_ASSERT(client->stream->Read(&client_status)); |
Craig Tiller | f282514 | 2015-03-03 17:15:36 -0800 | [diff] [blame] | 251 | const auto& stats = client_status.stats(); |
David Garcia Quintas | 0811650 | 2015-05-20 17:27:23 -0700 | [diff] [blame] | 252 | result->latencies.MergeProto(stats.latencies()); |
Vijay Pai | 4d06e2e | 2015-07-31 10:20:42 -0700 | [diff] [blame] | 253 | result->client_resources.emplace_back( |
| 254 | stats.time_elapsed(), stats.time_user(), stats.time_system()); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 255 | } |
| 256 | |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 257 | for (auto client = &clients[0]; client != &clients[num_clients]; client++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 258 | GPR_ASSERT(client->stream->WritesDone()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 259 | GPR_ASSERT(client->stream->Finish().ok()); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 260 | } |
Vijay Pai | eed63fa | 2015-08-05 23:08:34 +0000 | [diff] [blame] | 261 | for (auto server = &servers[0]; server != &servers[num_servers]; server++) { |
Vijay Pai | 82dd80a | 2015-03-24 10:36:08 -0700 | [diff] [blame] | 262 | GPR_ASSERT(server->stream->WritesDone()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 263 | GPR_ASSERT(server->stream->Finish().ok()); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 264 | } |
vjpai | b1db869 | 2015-08-11 22:41:02 -0700 | [diff] [blame] | 265 | delete[] clients; |
| 266 | delete[] servers; |
Craig Tiller | f282514 | 2015-03-03 17:15:36 -0800 | [diff] [blame] | 267 | return result; |
Craig Tiller | 4ef7a29 | 2015-02-23 17:29:01 -0800 | [diff] [blame] | 268 | } |
Craig Tiller | f282514 | 2015-03-03 17:15:36 -0800 | [diff] [blame] | 269 | } // namespace testing |
| 270 | } // namespace grpc |