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
c9f2693e
Commit
c9f2693e
authored
Nov 27, 2018
by
Roman Lebedev
Committed by
Eric
Nov 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StrFormat() is a printf-like function, mark it as such, fix fallout. (#727)
Fixes #714.
parent
c9311a44
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
benchmark_register.cc
src/benchmark_register.cc
+8
-3
string_util.h
src/string_util.h
+5
-1
reporter_output_test.cc
test/reporter_output_test.cc
+12
-0
No files found.
src/benchmark_register.cc
View file @
c9f2693e
...
...
@@ -182,14 +182,19 @@ bool BenchmarkFamilies::FindBenchmarks(
}
}
instance
.
name
+=
StrFormat
(
"%d"
,
arg
);
// we know that the args are always non-negative (see 'AddRange()'),
// thus print as 'unsigned'. BUT, do a cast due to the 32-bit builds.
instance
.
name
+=
StrFormat
(
"%lu"
,
static_cast
<
unsigned
long
>
(
arg
));
++
arg_i
;
}
if
(
!
IsZero
(
family
->
min_time_
))
instance
.
name
+=
StrFormat
(
"/min_time:%0.3f"
,
family
->
min_time_
);
if
(
family
->
iterations_
!=
0
)
instance
.
name
+=
StrFormat
(
"/iterations:%d"
,
family
->
iterations_
);
if
(
family
->
iterations_
!=
0
)
{
instance
.
name
+=
StrFormat
(
"/iterations:%lu"
,
static_cast
<
unsigned
long
>
(
family
->
iterations_
));
}
if
(
family
->
repetitions_
!=
0
)
instance
.
name
+=
StrFormat
(
"/repeats:%d"
,
family
->
repetitions_
);
...
...
src/string_util.h
View file @
c9f2693e
...
...
@@ -12,7 +12,11 @@ void AppendHumanReadable(int n, std::string* str);
std
::
string
HumanReadableNumber
(
double
n
,
double
one_k
=
1024
.
0
);
std
::
string
StrFormat
(
const
char
*
format
,
...);
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
1
,
2
)))
#endif
std
::
string
StrFormat
(
const
char
*
format
,
...);
inline
std
::
ostream
&
StrCatImp
(
std
::
ostream
&
out
)
BENCHMARK_NOEXCEPT
{
return
out
;
...
...
test/reporter_output_test.cc
View file @
c9f2693e
...
...
@@ -220,6 +220,18 @@ ADD_CASES(TC_JSONOut,
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_arg_names/first:2/5/third:4
\"
,%csv_report$"
}});
// ========================================================================= //
// ------------------------ Testing Big Args Output ------------------------ //
// ========================================================================= //
void
BM_BigArgs
(
benchmark
::
State
&
state
)
{
for
(
auto
_
:
state
)
{
}
}
BENCHMARK
(
BM_BigArgs
)
->
RangeMultiplier
(
2
)
->
Range
(
1U
<<
30U
,
1U
<<
31U
);
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_BigArgs/1073741824 %console_report$"
},
{
"^BM_BigArgs/2147483648 %console_report$"
}});
// ========================================================================= //
// ----------------------- Testing Complexity Output ----------------------- //
// ========================================================================= //
...
...
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