Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [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 | |
| 34 | #include <iostream> |
| 35 | #include <memory> |
| 36 | #include <string> |
Siddharth Rakesh | 3982433 | 2015-06-08 13:44:51 -0700 | [diff] [blame] | 37 | #include <cfloat> |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 38 | |
| 39 | #include <grpc/grpc.h> |
| 40 | #include <grpc++/channel_arguments.h> |
| 41 | #include <grpc++/channel_interface.h> |
| 42 | #include <grpc++/client_context.h> |
| 43 | #include <grpc++/create_channel.h> |
| 44 | #include <grpc++/credentials.h> |
| 45 | #include <grpc++/status.h> |
Siddharth Rakesh | cc5857b | 2015-06-18 16:45:55 -0700 | [diff] [blame] | 46 | #include "test/cpp/qps/perf_db.grpc.pb.h" |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 47 | |
Siddharth Rakesh | 3982433 | 2015-06-08 13:44:51 -0700 | [diff] [blame] | 48 | |
| 49 | namespace grpc{ |
| 50 | namespace testing { |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 51 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 52 | //Manages data sending to performance database server |
Siddharth Rakesh | cc5857b | 2015-06-18 16:45:55 -0700 | [diff] [blame] | 53 | class PerfDbClient { |
Siddharth Rakesh | 3982433 | 2015-06-08 13:44:51 -0700 | [diff] [blame] | 54 | public: |
Siddharth Rakesh | 60111c0 | 2015-06-22 13:02:33 -0700 | [diff] [blame] | 55 | PerfDbClient() { |
| 56 | QPS_ = DBL_MIN; |
| 57 | QPSPerCore_ = DBL_MIN; |
| 58 | percentileLatency50_ = DBL_MIN; |
| 59 | percentileLatency90_ = DBL_MIN; |
| 60 | percentileLatency95_ = DBL_MIN; |
| 61 | percentileLatency99_ = DBL_MIN; |
| 62 | percentileLatency99Point9_ = DBL_MIN; |
| 63 | serverSystemTime_ = DBL_MIN; |
| 64 | serverUserTime_ = DBL_MIN; |
| 65 | clientSystemTime_ = DBL_MIN; |
| 66 | clientUserTime_ = DBL_MIN; |
| 67 | } |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 68 | |
Siddharth Rakesh | cc5857b | 2015-06-18 16:45:55 -0700 | [diff] [blame] | 69 | void init(std::shared_ptr<ChannelInterface> channel) { stub_ = PerfDbTransfer::NewStub(channel); } |
| 70 | |
| 71 | ~PerfDbClient() {} |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 72 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 73 | //sets the client and server config information |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 74 | void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 75 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 76 | //sets the QPS |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 77 | void setQPS(double QPS); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 78 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 79 | //sets the QPS per core |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 80 | void setQPSPerCore(double QPSPerCore); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 81 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 82 | //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 83 | void setLatencies(double percentileLatency50, double percentileLatency90, |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 84 | double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 85 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 86 | //sets the server and client, user and system times |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 87 | void setTimes(double serverSystemTime, double serverUserTime, |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 88 | double clientSystemTime, double clientUserTime); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 89 | |
Siddharth Rakesh | d0010ae | 2015-06-15 17:02:51 -0700 | [diff] [blame] | 90 | //sends the data to the performancew database server |
Siddharth Rakesh | df77c58 | 2015-06-23 16:34:18 -0700 | [diff] [blame^] | 91 | int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag); |
Siddharth Rakesh | 922ea81 | 2015-06-04 17:32:31 -0700 | [diff] [blame] | 92 | |
Siddharth Rakesh | 3982433 | 2015-06-08 13:44:51 -0700 | [diff] [blame] | 93 | private: |
Siddharth Rakesh | cc5857b | 2015-06-18 16:45:55 -0700 | [diff] [blame] | 94 | std::unique_ptr<PerfDbTransfer::Stub> stub_; |
Siddharth Rakesh | 4364546 | 2015-06-22 12:21:57 -0700 | [diff] [blame] | 95 | ClientConfig clientConfig_; |
| 96 | ServerConfig serverConfig_; |
Siddharth Rakesh | 60111c0 | 2015-06-22 13:02:33 -0700 | [diff] [blame] | 97 | double QPS_; |
| 98 | double QPSPerCore_; |
| 99 | double percentileLatency50_; |
| 100 | double percentileLatency90_; |
| 101 | double percentileLatency95_; |
| 102 | double percentileLatency99_; |
| 103 | double percentileLatency99Point9_; |
| 104 | double serverSystemTime_; |
| 105 | double serverUserTime_; |
| 106 | double clientSystemTime_; |
| 107 | double clientUserTime_; |
Siddharth Rakesh | 3982433 | 2015-06-08 13:44:51 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | } //namespace testing |
| 111 | } //namespace grpc |
| 112 | |
| 113 | |