Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/grpc/test/cpp/qps/report.cc

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "test/cpp/qps/report.h"
35
36 #include <grpc/support/log.h>
37 #include "test/cpp/qps/driver.h"
38 #include "test/cpp/qps/stats.h"
39
40 namespace grpc {
41 namespace testing {
42
43 static double WallTime(ResourceUsage u) { return u.wall_time(); }
44 static double UserTime(ResourceUsage u) { return u.user_time(); }
45 static double SystemTime(ResourceUsage u) { return u.system_time(); }
46 static int Cores(ResourceUsage u) { return u.cores(); }
47
48 void CompositeReporter::add(std::unique_ptr<Reporter> reporter) {
49 reporters_.emplace_back(std::move(reporter));
50 }
51
52 void CompositeReporter::ReportQPS(const ScenarioResult& result) {
53 for (size_t i = 0; i < reporters_.size(); ++i) {
54 reporters_[i]->ReportQPS(result);
55 }
56 }
57
58 void CompositeReporter::ReportQPSPerCore(const ScenarioResult& result) {
59 for (size_t i = 0; i < reporters_.size(); ++i) {
60 reporters_[i]->ReportQPSPerCore(result);
61 }
62 }
63
64 void CompositeReporter::ReportLatency(const ScenarioResult& result) {
65 for (size_t i = 0; i < reporters_.size(); ++i) {
66 reporters_[i]->ReportLatency(result);
67 }
68 }
69
70 void CompositeReporter::ReportTimes(const ScenarioResult& result) {
71 for (size_t i = 0; i < reporters_.size(); ++i) {
72 reporters_[i]->ReportTimes(result);
73 }
74 }
75
76 void GprLogReporter::ReportQPS(const ScenarioResult& result) {
77 gpr_log(
78 GPR_INFO, "QPS: %.1f",
79 result.latencies.Count() / average(result.client_resources, WallTime));
80 }
81
82 void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) {
83 auto qps =
84 result.latencies.Count() / average(result.client_resources, WallTime);
85
86 gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps,
87 qps / sum(result.server_resources, Cores));
88 }
89
90 void GprLogReporter::ReportLatency(const ScenarioResult& result) {
91 gpr_log(GPR_INFO,
92 "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us",
93 result.latencies.Percentile(50) / 1000,
94 result.latencies.Percentile(90) / 1000,
95 result.latencies.Percentile(95) / 1000,
96 result.latencies.Percentile(99) / 1000,
97 result.latencies.Percentile(99.9) / 1000);
98 }
99
100 void GprLogReporter::ReportTimes(const ScenarioResult& result) {
101 gpr_log(GPR_INFO, "Server system time: %.2f%%",
102 100.0 * sum(result.server_resources, SystemTime) /
103 sum(result.server_resources, WallTime));
104 gpr_log(GPR_INFO, "Server user time: %.2f%%",
105 100.0 * sum(result.server_resources, UserTime) /
106 sum(result.server_resources, WallTime));
107 gpr_log(GPR_INFO, "Client system time: %.2f%%",
108 100.0 * sum(result.client_resources, SystemTime) /
109 sum(result.client_resources, WallTime));
110 gpr_log(GPR_INFO, "Client user time: %.2f%%",
111 100.0 * sum(result.client_resources, UserTime) /
112 sum(result.client_resources, WallTime));
113 }
114
115 void PerfDbReporter::ReportQPS(const ScenarioResult& result) {
116 auto qps =
117 result.latencies.Count() / average(result.client_resources, WallTime);
118
119 perf_db_client_.setQps(qps);
120 perf_db_client_.setConfigs(result.client_config, result.server_config);
121 }
122
123 void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) {
124 auto qps =
125 result.latencies.Count() / average(result.client_resources, WallTime);
126
127 auto qps_per_core = qps / sum(result.server_resources, Cores);
128
129 perf_db_client_.setQps(qps);
130 perf_db_client_.setQpsPerCore(qps_per_core);
131 perf_db_client_.setConfigs(result.client_config, result.server_config);
132 }
133
134 void PerfDbReporter::ReportLatency(const ScenarioResult& result) {
135 perf_db_client_.setLatencies(result.latencies.Percentile(50) / 1000,
136 result.latencies.Percentile(90) / 1000,
137 result.latencies.Percentile(95) / 1000,
138 result.latencies.Percentile(99) / 1000,
139 result.latencies.Percentile(99.9) / 1000);
140 perf_db_client_.setConfigs(result.client_config, result.server_config);
141 }
142
143 void PerfDbReporter::ReportTimes(const ScenarioResult& result) {
144 const double server_system_time = 100.0 *
145 sum(result.server_resources, SystemTime) /
146 sum(result.server_resources, WallTime);
147 const double server_user_time = 100.0 *
148 sum(result.server_resources, UserTime) /
149 sum(result.server_resources, WallTime);
150 const double client_system_time = 100.0 *
151 sum(result.client_resources, SystemTime) /
152 sum(result.client_resources, WallTime);
153 const double client_user_time = 100.0 *
154 sum(result.client_resources, UserTime) /
155 sum(result.client_resources, WallTime);
156
157 perf_db_client_.setTimes(server_system_time, server_user_time,
158 client_system_time, client_user_time);
159 perf_db_client_.setConfigs(result.client_config, result.server_config);
160 }
161
162 void PerfDbReporter::SendData() {
163 // send data to performance database
164 bool data_state =
165 perf_db_client_.sendData(hashed_id_, test_name_, sys_info_, tag_);
166
167 // check state of data sending
168 if (data_state) {
169 gpr_log(GPR_INFO, "Data sent to performance database successfully");
170 } else {
171 gpr_log(GPR_INFO, "Data could not be sent to performance database");
172 }
173 }
174
175 } // namespace testing
176 } // namespace grpc
OLDNEW
« no previous file with comments | « third_party/grpc/test/cpp/qps/report.h ('k') | third_party/grpc/test/cpp/qps/secure_sync_unary_ping_pong_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698