diff options
author | murgatroid99 <mlumish@google.com> | 2016-04-19 10:56:01 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2016-04-19 10:56:01 -0700 |
commit | e264e3984f6a5d8b730760d59930191a3a7c31e8 (patch) | |
tree | 7c3de6d924ae0e57cfcdab3bfee167e23ea8a546 /test/cpp/qps/report.cc | |
parent | 7d69ea63c8af9c7be43434993c82f93033343dce (diff) | |
parent | 279681311f61b079a720b7aef424cbe9000d08e8 (diff) |
Merged from master
Diffstat (limited to 'test/cpp/qps/report.cc')
-rw-r--r-- | test/cpp/qps/report.cc | 117 |
1 files changed, 39 insertions, 78 deletions
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index b230eb441e..3ae41399cf 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -33,6 +33,11 @@ #include "test/cpp/qps/report.h" +#include <fstream> + +#include <google/protobuf/util/json_util.h> +#include <google/protobuf/util/type_resolver_util.h> + #include <grpc/support/log.h> #include "test/cpp/qps/driver.h" #include "test/cpp/qps/stats.h" @@ -40,11 +45,6 @@ namespace grpc { namespace testing { -static double WallTime(ResourceUsage u) { return u.wall_time(); } -static double UserTime(ResourceUsage u) { return u.user_time(); } -static double SystemTime(ResourceUsage u) { return u.system_time(); } -static int Cores(ResourceUsage u) { return u.cores(); } - void CompositeReporter::add(std::unique_ptr<Reporter> reporter) { reporters_.emplace_back(std::move(reporter)); } @@ -74,102 +74,63 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) { } void GprLogReporter::ReportQPS(const ScenarioResult& result) { - gpr_log( - GPR_INFO, "QPS: %.1f", - result.latencies.Count() / average(result.client_resources, WallTime)); + gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps()); } void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) { - auto qps = - result.latencies.Count() / average(result.client_resources, WallTime); - - gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, - qps / sum(result.server_resources, Cores)); + gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", result.summary().qps(), + result.summary().qps_per_server_core()); } void GprLogReporter::ReportLatency(const ScenarioResult& result) { gpr_log(GPR_INFO, "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us", - result.latencies.Percentile(50) / 1000, - result.latencies.Percentile(90) / 1000, - result.latencies.Percentile(95) / 1000, - result.latencies.Percentile(99) / 1000, - result.latencies.Percentile(99.9) / 1000); + result.summary().latency_50() / 1000, + result.summary().latency_90() / 1000, + result.summary().latency_95() / 1000, + result.summary().latency_99() / 1000, + result.summary().latency_999() / 1000); } void GprLogReporter::ReportTimes(const ScenarioResult& result) { gpr_log(GPR_INFO, "Server system time: %.2f%%", - 100.0 * sum(result.server_resources, SystemTime) / - sum(result.server_resources, WallTime)); + result.summary().server_system_time()); gpr_log(GPR_INFO, "Server user time: %.2f%%", - 100.0 * sum(result.server_resources, UserTime) / - sum(result.server_resources, WallTime)); + result.summary().server_user_time()); gpr_log(GPR_INFO, "Client system time: %.2f%%", - 100.0 * sum(result.client_resources, SystemTime) / - sum(result.client_resources, WallTime)); + result.summary().client_system_time()); gpr_log(GPR_INFO, "Client user time: %.2f%%", - 100.0 * sum(result.client_resources, UserTime) / - sum(result.client_resources, WallTime)); + result.summary().client_user_time()); } -void PerfDbReporter::ReportQPS(const ScenarioResult& result) { - auto qps = - result.latencies.Count() / average(result.client_resources, WallTime); - - perf_db_client_.setQps(qps); - perf_db_client_.setConfigs(result.client_config, result.server_config); +void JsonReporter::ReportQPS(const ScenarioResult& result) { + std::unique_ptr<google::protobuf::util::TypeResolver> type_resolver( + google::protobuf::util::NewTypeResolverForDescriptorPool( + "type.googleapis.com", + google::protobuf::DescriptorPool::generated_pool())); + grpc::string binary; + grpc::string json_string; + result.SerializeToString(&binary); + auto status = BinaryToJsonString( + type_resolver.get(), "type.googleapis.com/grpc.testing.ScenarioResult", + binary, &json_string); + GPR_ASSERT(status.ok()); + + std::ofstream output_file(report_file_); + output_file << json_string; + output_file.close(); } -void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) { - auto qps = - result.latencies.Count() / average(result.client_resources, WallTime); - - auto qps_per_core = qps / sum(result.server_resources, Cores); - - perf_db_client_.setQps(qps); - perf_db_client_.setQpsPerCore(qps_per_core); - perf_db_client_.setConfigs(result.client_config, result.server_config); -} - -void PerfDbReporter::ReportLatency(const ScenarioResult& result) { - perf_db_client_.setLatencies(result.latencies.Percentile(50) / 1000, - result.latencies.Percentile(90) / 1000, - result.latencies.Percentile(95) / 1000, - result.latencies.Percentile(99) / 1000, - result.latencies.Percentile(99.9) / 1000); - perf_db_client_.setConfigs(result.client_config, result.server_config); +void JsonReporter::ReportQPSPerCore(const ScenarioResult& result) { + // NOP - all reporting is handled by ReportQPS. } -void PerfDbReporter::ReportTimes(const ScenarioResult& result) { - const double server_system_time = 100.0 * - sum(result.server_resources, SystemTime) / - sum(result.server_resources, WallTime); - const double server_user_time = 100.0 * - sum(result.server_resources, UserTime) / - sum(result.server_resources, WallTime); - const double client_system_time = 100.0 * - sum(result.client_resources, SystemTime) / - sum(result.client_resources, WallTime); - const double client_user_time = 100.0 * - sum(result.client_resources, UserTime) / - sum(result.client_resources, WallTime); - - perf_db_client_.setTimes(server_system_time, server_user_time, - client_system_time, client_user_time); - perf_db_client_.setConfigs(result.client_config, result.server_config); +void JsonReporter::ReportLatency(const ScenarioResult& result) { + // NOP - all reporting is handled by ReportQPS. } -void PerfDbReporter::SendData() { - // send data to performance database - bool data_state = - perf_db_client_.sendData(hashed_id_, test_name_, sys_info_, tag_); - - // check state of data sending - if (data_state) { - gpr_log(GPR_INFO, "Data sent to performance database successfully"); - } else { - gpr_log(GPR_INFO, "Data could not be sent to performance database"); - } +void JsonReporter::ReportTimes(const ScenarioResult& result) { + // NOP - all reporting is handled by ReportQPS. } } // namespace testing |