OLD | NEW |
(Empty) | |
| 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 |
| 34 #include <iostream> |
| 35 #include <memory> |
| 36 #include <string> |
| 37 #include <cfloat> |
| 38 |
| 39 #include <grpc/grpc.h> |
| 40 #include <grpc++/support/channel_arguments.h> |
| 41 #include <grpc++/channel.h> |
| 42 #include <grpc++/client_context.h> |
| 43 #include <grpc++/create_channel.h> |
| 44 #include <grpc++/security/credentials.h> |
| 45 #include "src/proto/grpc/testing/perf_db.grpc.pb.h" |
| 46 |
| 47 namespace grpc { |
| 48 namespace testing { |
| 49 |
| 50 // Manages data sending to performance database server |
| 51 class PerfDbClient { |
| 52 public: |
| 53 PerfDbClient() { |
| 54 qps_ = DBL_MIN; |
| 55 qps_per_core_ = DBL_MIN; |
| 56 perc_lat_50_ = DBL_MIN; |
| 57 perc_lat_90_ = DBL_MIN; |
| 58 perc_lat_95_ = DBL_MIN; |
| 59 perc_lat_99_ = DBL_MIN; |
| 60 perc_lat_99_point_9_ = DBL_MIN; |
| 61 server_system_time_ = DBL_MIN; |
| 62 server_user_time_ = DBL_MIN; |
| 63 client_system_time_ = DBL_MIN; |
| 64 client_user_time_ = DBL_MIN; |
| 65 } |
| 66 |
| 67 void init(std::shared_ptr<Channel> channel) { |
| 68 stub_ = PerfDbTransfer::NewStub(channel); |
| 69 } |
| 70 |
| 71 ~PerfDbClient() {} |
| 72 |
| 73 // sets the client and server config information |
| 74 void setConfigs(const ClientConfig& client_config, |
| 75 const ServerConfig& server_config); |
| 76 |
| 77 // sets the qps |
| 78 void setQps(double qps); |
| 79 |
| 80 // sets the qps per core |
| 81 void setQpsPerCore(double qps_per_core); |
| 82 |
| 83 // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency |
| 84 void setLatencies(double perc_lat_50, double perc_lat_90, double perc_lat_95, |
| 85 double perc_lat_99, double perc_lat_99_point_9); |
| 86 |
| 87 // sets the server and client, user and system times |
| 88 void setTimes(double server_system_time, double server_user_time, |
| 89 double client_system_time, double client_user_time); |
| 90 |
| 91 // sends the data to the performance database server |
| 92 bool sendData(std::string hashed_id, std::string test_name, |
| 93 std::string sys_info, std::string tag); |
| 94 |
| 95 private: |
| 96 std::unique_ptr<PerfDbTransfer::Stub> stub_; |
| 97 ClientConfig client_config_; |
| 98 ServerConfig server_config_; |
| 99 double qps_; |
| 100 double qps_per_core_; |
| 101 double perc_lat_50_; |
| 102 double perc_lat_90_; |
| 103 double perc_lat_95_; |
| 104 double perc_lat_99_; |
| 105 double perc_lat_99_point_9_; |
| 106 double server_system_time_; |
| 107 double server_user_time_; |
| 108 double client_system_time_; |
| 109 double client_user_time_; |
| 110 }; |
| 111 |
| 112 } // namespace testing |
| 113 } // namespace grpc |
OLD | NEW |