aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/qps_json_driver.cc6
-rw-r--r--test/cpp/qps/report.cc21
-rw-r--r--test/cpp/qps/report.h6
3 files changed, 30 insertions, 3 deletions
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index 8943a43ba8..e9266a5711 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -102,12 +102,16 @@ static void QpsDriver() {
for (int i = 0; i < scenarios.scenarios_size(); i++) {
const Scenario &scenario = scenarios.scenarios(i);
std::cerr << "RUNNING SCENARIO: " << scenario.name() << "\n";
- const auto result =
+ auto result =
RunScenario(scenario.client_config(), scenario.num_clients(),
scenario.server_config(), scenario.num_servers(),
scenario.warmup_seconds(), scenario.benchmark_seconds(),
scenario.spawn_local_worker_count());
+ // Amend the result with scenario config. Eventually we should adjust
+ // RunScenario contract so we don't need to touch the result here.
+ result->mutable_scenario()->CopyFrom(scenario);
+
GetReporter()->ReportQPS(*result);
GetReporter()->ReportQPSPerCore(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index 6037ac7603..05fb111120 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"
@@ -120,7 +125,21 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) {
}
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 JsonReporter::ReportQPSPerCore(const ScenarioResult& result) {
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index b299e415f1..e32a129e76 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -107,13 +107,17 @@ class GprLogReporter : public Reporter {
/** Dumps the report to a JSON file. */
class JsonReporter : public Reporter {
public:
- JsonReporter(const string& name) : Reporter(name) {}
+ JsonReporter(const string& name, const string& report_file) :
+ Reporter(name),
+ report_file_(report_file) {}
private:
void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE;
+
+ const string report_file_;
};
} // namespace testing