mirror of
https://github.com/google/benchmark.git
synced 2024-11-28 15:34:33 +00:00
Fix: --benchmark_counters_tabular was not being passed to tests.
This commit is contained in:
parent
615151723e
commit
17a012d754
|
@ -542,6 +542,26 @@ std::unique_ptr<BenchmarkReporter> CreateReporter(
|
|||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color) {
|
||||
int output_opts = ConsoleReporter::OO_Defaults;
|
||||
if ((FLAGS_benchmark_color == "auto" && IsColorTerminal()) ||
|
||||
IsTruthyFlagValue(FLAGS_benchmark_color)) {
|
||||
output_opts |= ConsoleReporter::OO_Color;
|
||||
} else {
|
||||
output_opts &= ~ConsoleReporter::OO_Color;
|
||||
}
|
||||
if(force_no_color) {
|
||||
output_opts &= ~ConsoleReporter::OO_Color;
|
||||
}
|
||||
if(FLAGS_benchmark_counters_tabular) {
|
||||
output_opts |= ConsoleReporter::OO_Tabular;
|
||||
} else {
|
||||
output_opts &= ~ConsoleReporter::OO_Tabular;
|
||||
}
|
||||
return static_cast< ConsoleReporter::OutputOptions >(output_opts);
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
size_t RunSpecifiedBenchmarks() {
|
||||
|
@ -563,21 +583,8 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
|
|||
std::unique_ptr<BenchmarkReporter> default_console_reporter;
|
||||
std::unique_ptr<BenchmarkReporter> default_file_reporter;
|
||||
if (!console_reporter) {
|
||||
int output_opts = ConsoleReporter::OO_Defaults;
|
||||
if ((FLAGS_benchmark_color == "auto" && IsColorTerminal()) ||
|
||||
IsTruthyFlagValue(FLAGS_benchmark_color)) {
|
||||
output_opts |= ConsoleReporter::OO_Color;
|
||||
} else {
|
||||
output_opts &= ~ConsoleReporter::OO_Color;
|
||||
}
|
||||
if(FLAGS_benchmark_counters_tabular) {
|
||||
output_opts |= ConsoleReporter::OO_Tabular;
|
||||
} else {
|
||||
output_opts &= ~ConsoleReporter::OO_Tabular;
|
||||
}
|
||||
default_console_reporter = internal::CreateReporter(
|
||||
FLAGS_benchmark_format,
|
||||
static_cast< ConsoleReporter::OutputOptions >(output_opts));
|
||||
FLAGS_benchmark_format, internal::GetOutputOptions());
|
||||
console_reporter = default_console_reporter.get();
|
||||
}
|
||||
auto& Out = console_reporter->GetOutputStream();
|
||||
|
|
|
@ -36,6 +36,8 @@ bool FindBenchmarksInternal(const std::string& re,
|
|||
std::vector<Benchmark::Instance>* benchmarks,
|
||||
std::ostream* Err);
|
||||
|
||||
ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false);
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsZero(double n) {
|
||||
|
|
|
@ -53,18 +53,19 @@ bool ConsoleReporter::ReportContext(const Context& context) {
|
|||
}
|
||||
|
||||
void ConsoleReporter::PrintHeader(const Run& run) {
|
||||
std::string str = FormatString("%-*s %13s %13s %10s\n", static_cast<int>(name_field_width_),
|
||||
std::string str = FormatString("%-*s %13s %13s %10s", static_cast<int>(name_field_width_),
|
||||
"Benchmark", "Time", "CPU", "Iterations");
|
||||
if(!run.counters.empty()) {
|
||||
if(output_options_ & OO_Tabular) {
|
||||
for(auto const& c : run.counters) {
|
||||
str += FormatString(" %10s", c.first);
|
||||
str += FormatString(" %10s", c.first.c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
str += " UserCounters...";
|
||||
}
|
||||
}
|
||||
str += "\n";
|
||||
std::string line = std::string(str.length(), '-');
|
||||
GetOutputStream() << line << "\n" << str << line << "\n";
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../src/check.h" // NOTE: check.h is for internal use only!
|
||||
#include "../src/re.h" // NOTE: re.h is for internal use only
|
||||
#include "output_test.h"
|
||||
#include "../src/benchmark_api_internal.h"
|
||||
|
||||
// ========================================================================= //
|
||||
// ------------------------------ Internals -------------------------------- //
|
||||
|
@ -367,7 +368,8 @@ int SetSubstitutions(
|
|||
void RunOutputTests(int argc, char* argv[]) {
|
||||
using internal::GetTestCaseList;
|
||||
benchmark::Initialize(&argc, argv);
|
||||
benchmark::ConsoleReporter CR(benchmark::ConsoleReporter::OO_None);
|
||||
auto options = benchmark::internal::GetOutputOptions(/*force_no_color*/true);
|
||||
benchmark::ConsoleReporter CR(options);
|
||||
benchmark::JSONReporter JR;
|
||||
benchmark::CSVReporter CSVR;
|
||||
struct ReporterTest {
|
||||
|
|
Loading…
Reference in a new issue