Improvements to reporting mechanism based on comments.
Turned the reporter into a composite, much cleaner arch.
diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc
index 914afa9..1b15ddc 100644
--- a/test/cpp/util/benchmark_config.cc
+++ b/test/cpp/util/benchmark_config.cc
@@ -51,12 +51,18 @@
ParseCommandLineFlags(argc, argv, remove_flags);
}
-std::vector<std::unique_ptr<Reporter> > InitBenchmarkReporters() {
- std::vector<std::unique_ptr<Reporter> > reporters;
+static std::shared_ptr<Reporter> InitBenchmarkReporters() {
+ auto* composite_reporter = new CompositeReporter;
if (FLAGS_enable_log_reporter) {
- reporters.emplace_back(new GprLogReporter("LogReporter"));
+ composite_reporter->add(
+ std::unique_ptr<Reporter>(new GprLogReporter("LogReporter")));
}
- return reporters;
+ return std::shared_ptr<Reporter>(composite_reporter);
+}
+
+const std::shared_ptr<Reporter>& GetReporter() {
+ static std::shared_ptr<Reporter> reporter(InitBenchmarkReporters());
+ return reporter;
}
} // namespace testing