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 #ifndef TEST_QPS_REPORT_H |
| 35 #define TEST_QPS_REPORT_H |
| 36 |
| 37 #include <memory> |
| 38 #include <set> |
| 39 #include <vector> |
| 40 |
| 41 #include <grpc++/support/config.h> |
| 42 |
| 43 #include "test/cpp/qps/driver.h" |
| 44 #include "test/cpp/qps/perf_db_client.h" |
| 45 |
| 46 namespace grpc { |
| 47 namespace testing { |
| 48 |
| 49 /** Interface for all reporters. */ |
| 50 class Reporter { |
| 51 public: |
| 52 /** Construct a reporter with the given \a name. */ |
| 53 Reporter(const string& name) : name_(name) {} |
| 54 |
| 55 virtual ~Reporter() {} |
| 56 |
| 57 /** Returns this reporter's name. |
| 58 * |
| 59 * Names are constants, set at construction time. */ |
| 60 string name() const { return name_; } |
| 61 |
| 62 /** Reports QPS for the given \a result. */ |
| 63 virtual void ReportQPS(const ScenarioResult& result) = 0; |
| 64 |
| 65 /** Reports QPS per core as (YYY/server core). */ |
| 66 virtual void ReportQPSPerCore(const ScenarioResult& result) = 0; |
| 67 |
| 68 /** Reports latencies for the 50, 90, 95, 99 and 99.9 percentiles, in ms. */ |
| 69 virtual void ReportLatency(const ScenarioResult& result) = 0; |
| 70 |
| 71 /** Reports system and user time for client and server systems. */ |
| 72 virtual void ReportTimes(const ScenarioResult& result) = 0; |
| 73 |
| 74 private: |
| 75 const string name_; |
| 76 }; |
| 77 |
| 78 /** A composite for all reporters to be considered. */ |
| 79 class CompositeReporter : public Reporter { |
| 80 public: |
| 81 CompositeReporter() : Reporter("CompositeReporter") {} |
| 82 |
| 83 /** Adds a \a reporter to the composite. */ |
| 84 void add(std::unique_ptr<Reporter> reporter); |
| 85 |
| 86 void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE; |
| 87 void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE; |
| 88 void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE; |
| 89 void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE; |
| 90 |
| 91 private: |
| 92 std::vector<std::unique_ptr<Reporter> > reporters_; |
| 93 }; |
| 94 |
| 95 /** Reporter to gpr_log(GPR_INFO). */ |
| 96 class GprLogReporter : public Reporter { |
| 97 public: |
| 98 GprLogReporter(const string& name) : Reporter(name) {} |
| 99 |
| 100 private: |
| 101 void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE; |
| 102 void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE; |
| 103 void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE; |
| 104 void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE; |
| 105 }; |
| 106 |
| 107 /** Reporter for performance database tool */ |
| 108 class PerfDbReporter : public Reporter { |
| 109 public: |
| 110 PerfDbReporter(const string& name, const string& hashed_id, |
| 111 const string& test_name, const string& sys_info, |
| 112 const string& server_address, const string& tag) |
| 113 : Reporter(name), |
| 114 hashed_id_(hashed_id), |
| 115 test_name_(test_name), |
| 116 sys_info_(sys_info), |
| 117 tag_(tag) { |
| 118 perf_db_client_.init(grpc::CreateChannel( |
| 119 server_address, grpc::InsecureChannelCredentials())); |
| 120 } |
| 121 ~PerfDbReporter() GRPC_OVERRIDE { SendData(); }; |
| 122 |
| 123 private: |
| 124 PerfDbClient perf_db_client_; |
| 125 std::string hashed_id_; |
| 126 std::string test_name_; |
| 127 std::string sys_info_; |
| 128 std::string tag_; |
| 129 void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE; |
| 130 void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE; |
| 131 void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE; |
| 132 void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE; |
| 133 void SendData(); |
| 134 }; |
| 135 |
| 136 } // namespace testing |
| 137 } // namespace grpc |
| 138 |
| 139 #endif |
OLD | NEW |