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

Side by Side Diff: third_party/grpc/test/cpp/qps/perf_db_client.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/perf_db_client.h"
35
36 namespace grpc {
37 namespace testing {
38
39 // sets the client and server config information
40 void PerfDbClient::setConfigs(const ClientConfig& client_config,
41 const ServerConfig& server_config) {
42 client_config_ = client_config;
43 server_config_ = server_config;
44 }
45
46 // sets the QPS
47 void PerfDbClient::setQps(double qps) { qps_ = qps; }
48
49 // sets the QPS per core
50 void PerfDbClient::setQpsPerCore(double qps_per_core) {
51 qps_per_core_ = qps_per_core;
52 }
53
54 // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
55 void PerfDbClient::setLatencies(double perc_lat_50, double perc_lat_90,
56 double perc_lat_95, double perc_lat_99,
57 double perc_lat_99_point_9) {
58 perc_lat_50_ = perc_lat_50;
59 perc_lat_90_ = perc_lat_90;
60 perc_lat_95_ = perc_lat_95;
61 perc_lat_99_ = perc_lat_99;
62 perc_lat_99_point_9_ = perc_lat_99_point_9;
63 }
64
65 // sets the server and client, user and system times
66 void PerfDbClient::setTimes(double server_system_time, double server_user_time,
67 double client_system_time,
68 double client_user_time) {
69 server_system_time_ = server_system_time;
70 server_user_time_ = server_user_time;
71 client_system_time_ = client_system_time;
72 client_user_time_ = client_user_time;
73 }
74
75 // sends the data to the performance database server
76 bool PerfDbClient::sendData(std::string hashed_id, std::string test_name,
77 std::string sys_info, std::string tag) {
78 // Data record request object
79 SingleUserRecordRequest single_user_record_request;
80
81 // setting access token, name of the test and the system information
82 single_user_record_request.set_hashed_id(hashed_id);
83 single_user_record_request.set_test_name(test_name);
84 single_user_record_request.set_sys_info(sys_info);
85 single_user_record_request.set_tag(tag);
86
87 // setting configs
88 *(single_user_record_request.mutable_client_config()) = client_config_;
89 *(single_user_record_request.mutable_server_config()) = server_config_;
90
91 Metrics* metrics = single_user_record_request.mutable_metrics();
92
93 // setting metrcs in data record request
94 if (qps_ != DBL_MIN) {
95 metrics->set_qps(qps_);
96 }
97 if (qps_per_core_ != DBL_MIN) {
98 metrics->set_qps_per_core(qps_per_core_);
99 }
100 if (perc_lat_50_ != DBL_MIN) {
101 metrics->set_perc_lat_50(perc_lat_50_);
102 }
103 if (perc_lat_90_ != DBL_MIN) {
104 metrics->set_perc_lat_90(perc_lat_90_);
105 }
106 if (perc_lat_95_ != DBL_MIN) {
107 metrics->set_perc_lat_95(perc_lat_95_);
108 }
109 if (perc_lat_99_ != DBL_MIN) {
110 metrics->set_perc_lat_99(perc_lat_99_);
111 }
112 if (perc_lat_99_point_9_ != DBL_MIN) {
113 metrics->set_perc_lat_99_point_9(perc_lat_99_point_9_);
114 }
115 if (server_system_time_ != DBL_MIN) {
116 metrics->set_server_system_time(server_system_time_);
117 }
118 if (server_user_time_ != DBL_MIN) {
119 metrics->set_server_user_time(server_user_time_);
120 }
121 if (client_system_time_ != DBL_MIN) {
122 metrics->set_client_system_time(client_system_time_);
123 }
124 if (client_user_time_ != DBL_MIN) {
125 metrics->set_client_user_time(client_user_time_);
126 }
127
128 SingleUserRecordReply single_user_record_reply;
129 ClientContext context;
130
131 Status status = stub_->RecordSingleClientData(
132 &context, single_user_record_request, &single_user_record_reply);
133 if (status.ok()) {
134 return true; // data sent to database successfully
135 } else {
136 return false; // error in data sending
137 }
138 }
139 } // testing
140 } // grpc
OLDNEW
« no previous file with comments | « third_party/grpc/test/cpp/qps/perf_db_client.h ('k') | third_party/grpc/test/cpp/qps/qps-sweep.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698