Skip to content
Snippets Groups Projects
Commit 33c161df authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

populate ScenarioResult.summary in JSON report

parent ac4251aa
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "test/cpp/qps/driver.h" #include "test/cpp/qps/driver.h"
#include "test/cpp/qps/histogram.h" #include "test/cpp/qps/histogram.h"
#include "test/cpp/qps/qps_worker.h" #include "test/cpp/qps/qps_worker.h"
#include "test/cpp/qps/stats.h"
using std::list; using std::list;
using std::thread; using std::thread;
...@@ -115,6 +116,46 @@ static deque<string> get_workers(const string& name) { ...@@ -115,6 +116,46 @@ static deque<string> get_workers(const string& name) {
} }
} }
// helpers for postprocess_scenario_result
static double WallTime(ClientStats s) { return s.time_elapsed(); }
static double SystemTime(ClientStats s) { return s.time_system(); }
static double UserTime(ClientStats s) { return s.time_user(); }
static double ServerWallTime(ServerStats s) { return s.time_elapsed(); }
static double ServerSystemTime(ServerStats s) { return s.time_system(); }
static double ServerUserTime(ServerStats s) { return s.time_user(); }
static int Cores(int n) { return n; }
// Postprocess ScenarioResult and populate result summary.
static void postprocess_scenario_result(ScenarioResult* result) {
Histogram histogram;
histogram.MergeProto(result->latencies());
auto qps = histogram.Count() / average(result->client_stats(), WallTime);
auto qps_per_server_core = qps / sum(result->server_cores(), Cores);
result->mutable_summary()->set_qps(qps);
result->mutable_summary()->set_qps_per_server_core(qps_per_server_core);
result->mutable_summary()->set_latency_50(histogram.Percentile(50));
result->mutable_summary()->set_latency_90(histogram.Percentile(90));
result->mutable_summary()->set_latency_95(histogram.Percentile(95));
result->mutable_summary()->set_latency_99(histogram.Percentile(99));
result->mutable_summary()->set_latency_999(histogram.Percentile(99.9));
auto server_system_time = 100.0 * sum(result->server_stats(), ServerSystemTime) /
sum(result->server_stats(), ServerWallTime);
auto server_user_time = 100.0 * sum(result->server_stats(), ServerUserTime) /
sum(result->server_stats(), ServerWallTime);
auto client_system_time = 100.0 * sum(result->client_stats(), SystemTime) /
sum(result->client_stats(), WallTime);
auto client_user_time = 100.0 * sum(result->client_stats(), UserTime) /
sum(result->client_stats(), WallTime);
result->mutable_summary()->set_server_system_time(server_system_time);
result->mutable_summary()->set_server_user_time(server_user_time);
result->mutable_summary()->set_client_system_time(client_system_time);
result->mutable_summary()->set_client_user_time(client_user_time);
}
// Namespace for classes and functions used only in RunScenario // Namespace for classes and functions used only in RunScenario
// Using this rather than local definitions to workaround gcc-4.4 limitations // Using this rather than local definitions to workaround gcc-4.4 limitations
// regarding using templates without linkage // regarding using templates without linkage
...@@ -380,6 +421,8 @@ std::unique_ptr<ScenarioResult> RunScenario( ...@@ -380,6 +421,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
} }
delete[] servers; delete[] servers;
postprocess_scenario_result(result.get());
return result; return result;
} }
......
...@@ -45,14 +45,6 @@ ...@@ -45,14 +45,6 @@
namespace grpc { namespace grpc {
namespace testing { namespace testing {
static double WallTime(ClientStats s) { return s.time_elapsed(); }
static double SystemTime(ClientStats s) { return s.time_system(); }
static double UserTime(ClientStats s) { return s.time_user(); }
static double ServerWallTime(ServerStats s) { return s.time_elapsed(); }
static double ServerSystemTime(ServerStats s) { return s.time_system(); }
static double ServerUserTime(ServerStats s) { return s.time_user(); }
static int Cores(int n) { return n; }
void CompositeReporter::add(std::unique_ptr<Reporter> reporter) { void CompositeReporter::add(std::unique_ptr<Reporter> reporter) {
reporters_.emplace_back(std::move(reporter)); reporters_.emplace_back(std::move(reporter));
} }
...@@ -82,44 +74,34 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) { ...@@ -82,44 +74,34 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) {
} }
void GprLogReporter::ReportQPS(const ScenarioResult& result) { void GprLogReporter::ReportQPS(const ScenarioResult& result) {
Histogram histogram; gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps());
histogram.MergeProto(result.latencies());
gpr_log(GPR_INFO, "QPS: %.1f",
histogram.Count() / average(result.client_stats(), WallTime));
} }
void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) { void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) {
Histogram histogram; gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)",
histogram.MergeProto(result.latencies()); result.summary().qps(),
auto qps = histogram.Count() / average(result.client_stats(), WallTime); result.summary().qps_per_server_core());
gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps,
qps / sum(result.server_cores(), Cores));
} }
void GprLogReporter::ReportLatency(const ScenarioResult& result) { void GprLogReporter::ReportLatency(const ScenarioResult& result) {
Histogram histogram;
histogram.MergeProto(result.latencies());
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us", "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us",
histogram.Percentile(50) / 1000, histogram.Percentile(90) / 1000, result.summary().latency_50() / 1000,
histogram.Percentile(95) / 1000, histogram.Percentile(99) / 1000, result.summary().latency_90() / 1000,
histogram.Percentile(99.9) / 1000); result.summary().latency_95() / 1000,
result.summary().latency_99() / 1000,
result.summary().latency_999() / 1000);
} }
void GprLogReporter::ReportTimes(const ScenarioResult& result) { void GprLogReporter::ReportTimes(const ScenarioResult& result) {
gpr_log(GPR_INFO, "Server system time: %.2f%%", gpr_log(GPR_INFO, "Server system time: %.2f%%",
100.0 * sum(result.server_stats(), ServerSystemTime) / result.summary().server_system_time());
sum(result.server_stats(), ServerWallTime));
gpr_log(GPR_INFO, "Server user time: %.2f%%", gpr_log(GPR_INFO, "Server user time: %.2f%%",
100.0 * sum(result.server_stats(), ServerUserTime) / result.summary().server_user_time());
sum(result.server_stats(), ServerWallTime));
gpr_log(GPR_INFO, "Client system time: %.2f%%", gpr_log(GPR_INFO, "Client system time: %.2f%%",
100.0 * sum(result.client_stats(), SystemTime) / result.summary().client_system_time());
sum(result.client_stats(), WallTime));
gpr_log(GPR_INFO, "Client user time: %.2f%%", gpr_log(GPR_INFO, "Client user time: %.2f%%",
100.0 * sum(result.client_stats(), UserTime) / result.summary().client_user_time());
sum(result.client_stats(), WallTime));
} }
void JsonReporter::ReportQPS(const ScenarioResult& result) { void JsonReporter::ReportQPS(const ScenarioResult& result) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment