-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add command line option to print user counters in tabular format #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❌ Build benchmark 540 failed (commit e0e3889b33 by @biojppm) |
Changes Unknown when pulling 0de985a on biojppm:compact into ** on google:master**. |
src/benchmark.cc
Outdated
output_opts &= ~ConsoleReporter::OO_Tabular; | ||
} | ||
default_console_reporter = internal::CreateReporter( | ||
FLAGS_benchmark_format, (ConsoleReporter::OutputOptions)output_opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use c++-style casts please.
prev_counters_.clear(); | ||
|
||
PrintBasicContext(&GetErrorStream(), context); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to update the WINDOWS build too. color_output_ is referenced in there.
❌ Build benchmark 541 failed (commit 4ec49b8a30 by @biojppm) |
Changes Unknown when pulling c846eed on biojppm:compact into ** on google:master**. |
Changes Unknown when pulling d84d911 on biojppm:compact into ** on google:master**. |
❌ Build benchmark 542 failed (commit 10bc6154fe by @biojppm) |
Looks like one of the tests is failing for MinGW relating to console output. Could you take a look? |
@dominichamon Sorry for the late reply. I did see that MinGW fail when I first pushed; I thought it was a spurious fail which I've sometimes seen with the output test. Looking more closely, it is indeed something in the output test, and AFAICT it is unrelated to any counter logic; here's the message:
|
Changes Unknown when pulling 707dd89 on biojppm:compact into ** on google:master**. |
✅ Build benchmark 570 completed (commit 3ce9f21d60 by @biojppm) |
@dominichamon Indeed, the (same) PR is now passing Appveyor's MinGW test. |
src/console_reporter.cc
Outdated
if(!run.counters.empty()) { | ||
if(output_options_ & OO_Tabular) { | ||
for(auto const& c : run.counters) { | ||
str += FormatString(" %10s", c.first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.first.c_str() i think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! :-P
❌ Build benchmark 616 failed (commit d5091285f8 by @biojppm) |
src/benchmark_api_internal.h
Outdated
|
||
namespace { | ||
|
||
bool IsZero(double n) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused function, apparently? in travis (clang release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed by pragma-ignoring it, is it OK?
src/csv_reporter.cc
Outdated
if(it == run.counters.end()) { | ||
Out << ","; | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dropped 'else' isn't google style. can you run this change through clang-format with Google style selected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
❌ Build benchmark 617 failed (commit b0458113f2 by @biojppm) |
@dominichamon The previous push happened by accident. This push (or more precisely this push sequence) now completes the PR with unit tests. There may be some details which are so-so (the pragma ignore for -Wunused-function comes to mind, or the // clang format off), but other than that I think that's it. |
❌ Build benchmark 618 failed (commit 09866a07f8 by @biojppm) |
This thing with the pragma ignore was getting out of hand: now MinGW (and probably GCC) was erroring too. So I chose to move the definition of IsZero() out of the anonymous namespace into benchmark.cc.
Hmmm. This thing with the pragma ignore is getting out of hand: now MinGW is complaining. I took the liberty of moving the definition of IsZero() out of the anonymous namespace into benchmark.cc. |
✅ Build benchmark 619 completed (commit 02184fedf1 by @biojppm) |
✅ Build benchmark 620 completed (commit 03d2027393 by @biojppm) |
This PR adds the option
--benchmark_counters_tabular={true|false}
, which makes the ConsoleReporter print the user counters in tabular format. The option defaults to false. This follows discussions in PR #262 (notably this and this).To be clear:
--benchmark_counters_tabular=true
is given, then the counters are printed as a column of the table. This is best for cases in which there are a lot of counters, or a lot of lines per benchmark.Here's an example comparison between the two versions (Note that I removed some whitespace from both examples).
First the default
--benchmark_counters_tabular=false
:... compared to the tabular version
--benchmark_counters_tabular=true
. Note the additional printing of the header. This will happen any time the counter set changes.