Unverified Commit d9cab612 by Roman Lebedev Committed by GitHub

[NFC] s/console_reporter/display_reporter/ (#663)

There are two destinations: * display (console, terminal) and * file. And each of the destinations can be poplulated with one of the reporters: * console - human-friendly table-like display * json * csv (deprecated) So using the name console_reporter is confusing. Is it talking about the console reporter in the sense of table-like reporter, or in the sense of display destination?
parent a0018c39
...@@ -268,7 +268,7 @@ bool ReportUnrecognizedArguments(int argc, char** argv); ...@@ -268,7 +268,7 @@ bool ReportUnrecognizedArguments(int argc, char** argv);
// of each matching benchmark. Otherwise run each matching benchmark and // of each matching benchmark. Otherwise run each matching benchmark and
// report the results. // report the results.
// //
// The second and third overload use the specified 'console_reporter' and // The second and third overload use the specified 'display_reporter' and
// 'file_reporter' respectively. 'file_reporter' will write to the file // 'file_reporter' respectively. 'file_reporter' will write to the file
// specified // specified
// by '--benchmark_output'. If '--benchmark_output' is not given the // by '--benchmark_output'. If '--benchmark_output' is not given the
...@@ -276,8 +276,8 @@ bool ReportUnrecognizedArguments(int argc, char** argv); ...@@ -276,8 +276,8 @@ bool ReportUnrecognizedArguments(int argc, char** argv);
// //
// RETURNS: The number of matching benchmarks. // RETURNS: The number of matching benchmarks.
size_t RunSpecifiedBenchmarks(); size_t RunSpecifiedBenchmarks();
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter); size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter);
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
BenchmarkReporter* file_reporter); BenchmarkReporter* file_reporter);
// Register a MemoryManager instance that will be used to collect and report // Register a MemoryManager instance that will be used to collect and report
......
...@@ -424,10 +424,10 @@ namespace internal { ...@@ -424,10 +424,10 @@ namespace internal {
namespace { namespace {
void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks, void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
BenchmarkReporter* console_reporter, BenchmarkReporter* display_reporter,
BenchmarkReporter* file_reporter) { BenchmarkReporter* file_reporter) {
// Note the file_reporter can be null. // Note the file_reporter can be null.
CHECK(console_reporter != nullptr); CHECK(display_reporter != nullptr);
// Determine the width of the name field using a minimum width of 10. // Determine the width of the name field using a minimum width of 10.
bool has_repetitions = FLAGS_benchmark_repetitions > 1; bool has_repetitions = FLAGS_benchmark_repetitions > 1;
...@@ -458,22 +458,22 @@ void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks, ...@@ -458,22 +458,22 @@ void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
std::flush(reporter->GetErrorStream()); std::flush(reporter->GetErrorStream());
}; };
if (console_reporter->ReportContext(context) && if (display_reporter->ReportContext(context) &&
(!file_reporter || file_reporter->ReportContext(context))) { (!file_reporter || file_reporter->ReportContext(context))) {
flushStreams(console_reporter); flushStreams(display_reporter);
flushStreams(file_reporter); flushStreams(file_reporter);
for (const auto& benchmark : benchmarks) { for (const auto& benchmark : benchmarks) {
std::vector<BenchmarkReporter::Run> reports = std::vector<BenchmarkReporter::Run> reports =
RunBenchmark(benchmark, &complexity_reports); RunBenchmark(benchmark, &complexity_reports);
console_reporter->ReportRuns(reports); display_reporter->ReportRuns(reports);
if (file_reporter) file_reporter->ReportRuns(reports); if (file_reporter) file_reporter->ReportRuns(reports);
flushStreams(console_reporter); flushStreams(display_reporter);
flushStreams(file_reporter); flushStreams(file_reporter);
} }
} }
console_reporter->Finalize(); display_reporter->Finalize();
if (file_reporter) file_reporter->Finalize(); if (file_reporter) file_reporter->Finalize();
flushStreams(console_reporter); flushStreams(display_reporter);
flushStreams(file_reporter); flushStreams(file_reporter);
} }
...@@ -523,11 +523,11 @@ size_t RunSpecifiedBenchmarks() { ...@@ -523,11 +523,11 @@ size_t RunSpecifiedBenchmarks() {
return RunSpecifiedBenchmarks(nullptr, nullptr); return RunSpecifiedBenchmarks(nullptr, nullptr);
} }
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter) { size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter) {
return RunSpecifiedBenchmarks(console_reporter, nullptr); return RunSpecifiedBenchmarks(display_reporter, nullptr);
} }
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
BenchmarkReporter* file_reporter) { BenchmarkReporter* file_reporter) {
std::string spec = FLAGS_benchmark_filter; std::string spec = FLAGS_benchmark_filter;
if (spec.empty() || spec == "all") if (spec.empty() || spec == "all")
...@@ -535,15 +535,15 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, ...@@ -535,15 +535,15 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
// Setup the reporters // Setup the reporters
std::ofstream output_file; std::ofstream output_file;
std::unique_ptr<BenchmarkReporter> default_console_reporter; std::unique_ptr<BenchmarkReporter> default_display_reporter;
std::unique_ptr<BenchmarkReporter> default_file_reporter; std::unique_ptr<BenchmarkReporter> default_file_reporter;
if (!console_reporter) { if (!display_reporter) {
default_console_reporter = internal::CreateReporter( default_display_reporter = internal::CreateReporter(
FLAGS_benchmark_format, internal::GetOutputOptions()); FLAGS_benchmark_format, internal::GetOutputOptions());
console_reporter = default_console_reporter.get(); display_reporter = default_display_reporter.get();
} }
auto& Out = console_reporter->GetOutputStream(); auto& Out = display_reporter->GetOutputStream();
auto& Err = console_reporter->GetErrorStream(); auto& Err = display_reporter->GetErrorStream();
std::string const& fname = FLAGS_benchmark_out; std::string const& fname = FLAGS_benchmark_out;
if (fname.empty() && file_reporter) { if (fname.empty() && file_reporter) {
...@@ -578,7 +578,7 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter, ...@@ -578,7 +578,7 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
if (FLAGS_benchmark_list_tests) { if (FLAGS_benchmark_list_tests) {
for (auto const& benchmark : benchmarks) Out << benchmark.name << "\n"; for (auto const& benchmark : benchmarks) Out << benchmark.name << "\n";
} else { } else {
internal::RunBenchmarks(benchmarks, console_reporter, file_reporter); internal::RunBenchmarks(benchmarks, display_reporter, file_reporter);
} }
return benchmarks.size(); return benchmarks.size();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment