aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/report.cc
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-04-14 12:59:42 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-04-14 13:13:25 -0700
commit969ffaf5c61aeec0c52a721d64b39528da233fd3 (patch)
tree43b99c43617edd23c2933a7f755e0b79f7bf00a7 /test/cpp/qps/report.cc
parentf2ba7fe037b4e97d727ba38603364c464144e2e9 (diff)
Enable JSON reports for qps drivers
Diffstat (limited to 'test/cpp/qps/report.cc')
-rw-r--r--test/cpp/qps/report.cc21
1 files changed, 20 insertions, 1 deletions
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) {