Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
17a012d7
Commit
17a012d7
authored
May 02, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: --benchmark_counters_tabular was not being passed to tests.
parent
61515172
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
17 deletions
+29
-17
benchmark.cc
src/benchmark.cc
+21
-14
benchmark_api_internal.h
src/benchmark_api_internal.h
+2
-0
console_reporter.cc
src/console_reporter.cc
+3
-2
output_test_helper.cc
test/output_test_helper.cc
+3
-1
No files found.
src/benchmark.cc
View file @
17a012d7
...
@@ -542,6 +542,26 @@ std::unique_ptr<BenchmarkReporter> CreateReporter(
...
@@ -542,6 +542,26 @@ std::unique_ptr<BenchmarkReporter> CreateReporter(
}
}
}
// end namespace
}
// 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
}
// end namespace internal
size_t
RunSpecifiedBenchmarks
()
{
size_t
RunSpecifiedBenchmarks
()
{
...
@@ -563,21 +583,8 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
...
@@ -563,21 +583,8 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
std
::
unique_ptr
<
BenchmarkReporter
>
default_console_reporter
;
std
::
unique_ptr
<
BenchmarkReporter
>
default_console_reporter
;
std
::
unique_ptr
<
BenchmarkReporter
>
default_file_reporter
;
std
::
unique_ptr
<
BenchmarkReporter
>
default_file_reporter
;
if
(
!
console_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
(
default_console_reporter
=
internal
::
CreateReporter
(
FLAGS_benchmark_format
,
FLAGS_benchmark_format
,
internal
::
GetOutputOptions
());
static_cast
<
ConsoleReporter
::
OutputOptions
>
(
output_opts
));
console_reporter
=
default_console_reporter
.
get
();
console_reporter
=
default_console_reporter
.
get
();
}
}
auto
&
Out
=
console_reporter
->
GetOutputStream
();
auto
&
Out
=
console_reporter
->
GetOutputStream
();
...
...
src/benchmark_api_internal.h
View file @
17a012d7
...
@@ -36,6 +36,8 @@ bool FindBenchmarksInternal(const std::string& re,
...
@@ -36,6 +36,8 @@ bool FindBenchmarksInternal(const std::string& re,
std
::
vector
<
Benchmark
::
Instance
>*
benchmarks
,
std
::
vector
<
Benchmark
::
Instance
>*
benchmarks
,
std
::
ostream
*
Err
);
std
::
ostream
*
Err
);
ConsoleReporter
::
OutputOptions
GetOutputOptions
(
bool
force_no_color
=
false
);
namespace
{
namespace
{
bool
IsZero
(
double
n
)
{
bool
IsZero
(
double
n
)
{
...
...
src/console_reporter.cc
View file @
17a012d7
...
@@ -53,18 +53,19 @@ bool ConsoleReporter::ReportContext(const Context& context) {
...
@@ -53,18 +53,19 @@ bool ConsoleReporter::ReportContext(const Context& context) {
}
}
void
ConsoleReporter
::
PrintHeader
(
const
Run
&
run
)
{
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"
);
"Benchmark"
,
"Time"
,
"CPU"
,
"Iterations"
);
if
(
!
run
.
counters
.
empty
())
{
if
(
!
run
.
counters
.
empty
())
{
if
(
output_options_
&
OO_Tabular
)
{
if
(
output_options_
&
OO_Tabular
)
{
for
(
auto
const
&
c
:
run
.
counters
)
{
for
(
auto
const
&
c
:
run
.
counters
)
{
str
+=
FormatString
(
" %10s"
,
c
.
first
);
str
+=
FormatString
(
" %10s"
,
c
.
first
.
c_str
()
);
}
}
}
}
else
{
else
{
str
+=
" UserCounters..."
;
str
+=
" UserCounters..."
;
}
}
}
}
str
+=
"
\n
"
;
std
::
string
line
=
std
::
string
(
str
.
length
(),
'-'
);
std
::
string
line
=
std
::
string
(
str
.
length
(),
'-'
);
GetOutputStream
()
<<
line
<<
"
\n
"
<<
str
<<
line
<<
"
\n
"
;
GetOutputStream
()
<<
line
<<
"
\n
"
<<
str
<<
line
<<
"
\n
"
;
}
}
...
...
test/output_test_helper.cc
View file @
17a012d7
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "../src/check.h" // NOTE: check.h is for internal use only!
#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 "../src/re.h" // NOTE: re.h is for internal use only
#include "output_test.h"
#include "output_test.h"
#include "../src/benchmark_api_internal.h"
// ========================================================================= //
// ========================================================================= //
// ------------------------------ Internals -------------------------------- //
// ------------------------------ Internals -------------------------------- //
...
@@ -367,7 +368,8 @@ int SetSubstitutions(
...
@@ -367,7 +368,8 @@ int SetSubstitutions(
void
RunOutputTests
(
int
argc
,
char
*
argv
[])
{
void
RunOutputTests
(
int
argc
,
char
*
argv
[])
{
using
internal
::
GetTestCaseList
;
using
internal
::
GetTestCaseList
;
benchmark
::
Initialize
(
&
argc
,
argv
);
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
::
JSONReporter
JR
;
benchmark
::
CSVReporter
CSVR
;
benchmark
::
CSVReporter
CSVR
;
struct
ReporterTest
{
struct
ReporterTest
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment