diff options
Diffstat (limited to 'test/cpp/qps/report.cc')
-rw-r--r-- | test/cpp/qps/report.cc | 21 |
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) { |