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
62937f91
Unverified
Commit
62937f91
authored
Jun 18, 2021
by
Dominic Hamon
Committed by
GitHub
Jun 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing trailing commas (#1182)
* Add missing trailing commas Fixes #1181 * Better trailing commas
parent
c932169e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
21 deletions
+43
-21
json_reporter.cc
src/json_reporter.cc
+43
-21
No files found.
src/json_reporter.cc
View file @
62937f91
...
@@ -12,9 +12,6 @@
...
@@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "benchmark/benchmark.h"
#include "complexity.h"
#include <algorithm>
#include <algorithm>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstdint>
...
@@ -25,6 +22,8 @@
...
@@ -25,6 +22,8 @@
#include <tuple>
#include <tuple>
#include <vector>
#include <vector>
#include "benchmark/benchmark.h"
#include "complexity.h"
#include "string_util.h"
#include "string_util.h"
#include "timers.h"
#include "timers.h"
...
@@ -35,34 +34,53 @@ extern std::map<std::string, std::string>* global_context;
...
@@ -35,34 +34,53 @@ extern std::map<std::string, std::string>* global_context;
namespace
{
namespace
{
std
::
string
StrEscape
(
const
std
::
string
&
s
)
{
std
::
string
StrEscape
(
const
std
::
string
&
s
)
{
std
::
string
tmp
;
std
::
string
tmp
;
tmp
.
reserve
(
s
.
size
());
tmp
.
reserve
(
s
.
size
());
for
(
char
c
:
s
)
{
for
(
char
c
:
s
)
{
switch
(
c
)
{
switch
(
c
)
{
case
'\b'
:
tmp
+=
"
\\
b"
;
break
;
case
'\b'
:
case
'\f'
:
tmp
+=
"
\\
f"
;
break
;
tmp
+=
"
\\
b"
;
case
'\n'
:
tmp
+=
"
\\
n"
;
break
;
break
;
case
'\r'
:
tmp
+=
"
\\
r"
;
break
;
case
'\f'
:
case
'\t'
:
tmp
+=
"
\\
t"
;
break
;
tmp
+=
"
\\
f"
;
case
'\\'
:
tmp
+=
"
\\\\
"
;
break
;
break
;
case
'"'
:
tmp
+=
"
\\\"
"
;
break
;
case
'\n'
:
default
:
tmp
+=
c
;
break
;
tmp
+=
"
\\
n"
;
break
;
case
'\r'
:
tmp
+=
"
\\
r"
;
break
;
case
'\t'
:
tmp
+=
"
\\
t"
;
break
;
case
'\\'
:
tmp
+=
"
\\\\
"
;
break
;
case
'"'
:
tmp
+=
"
\\\"
"
;
break
;
default
:
tmp
+=
c
;
break
;
}
}
}
}
return
tmp
;
return
tmp
;
}
}
std
::
string
FormatKV
(
std
::
string
const
&
key
,
std
::
string
const
&
value
)
{
std
::
string
FormatKV
(
std
::
string
const
&
key
,
std
::
string
const
&
value
)
{
return
StrFormat
(
"
\"
%s
\"
:
\"
%s
\"
"
,
StrEscape
(
key
).
c_str
(),
StrEscape
(
value
).
c_str
());
return
StrFormat
(
"
\"
%s
\"
:
\"
%s
\"
"
,
StrEscape
(
key
).
c_str
(),
StrEscape
(
value
).
c_str
());
}
}
std
::
string
FormatKV
(
std
::
string
const
&
key
,
const
char
*
value
)
{
std
::
string
FormatKV
(
std
::
string
const
&
key
,
const
char
*
value
)
{
return
StrFormat
(
"
\"
%s
\"
:
\"
%s
\"
"
,
StrEscape
(
key
).
c_str
(),
StrEscape
(
value
).
c_str
());
return
StrFormat
(
"
\"
%s
\"
:
\"
%s
\"
"
,
StrEscape
(
key
).
c_str
(),
StrEscape
(
value
).
c_str
());
}
}
std
::
string
FormatKV
(
std
::
string
const
&
key
,
bool
value
)
{
std
::
string
FormatKV
(
std
::
string
const
&
key
,
bool
value
)
{
return
StrFormat
(
"
\"
%s
\"
: %s"
,
StrEscape
(
key
).
c_str
(),
value
?
"true"
:
"false"
);
return
StrFormat
(
"
\"
%s
\"
: %s"
,
StrEscape
(
key
).
c_str
(),
value
?
"true"
:
"false"
);
}
}
std
::
string
FormatKV
(
std
::
string
const
&
key
,
int64_t
value
)
{
std
::
string
FormatKV
(
std
::
string
const
&
key
,
int64_t
value
)
{
...
@@ -126,7 +144,9 @@ bool JSONReporter::ReportContext(const Context& context) {
...
@@ -126,7 +144,9 @@ bool JSONReporter::ReportContext(const Context& context) {
RoundDouble
(
info
.
cycles_per_second
/
1000000.0
))
RoundDouble
(
info
.
cycles_per_second
/
1000000.0
))
<<
",
\n
"
;
<<
",
\n
"
;
if
(
CPUInfo
::
Scaling
::
UNKNOWN
!=
info
.
scaling
)
{
if
(
CPUInfo
::
Scaling
::
UNKNOWN
!=
info
.
scaling
)
{
out
<<
indent
<<
FormatKV
(
"cpu_scaling_enabled"
,
info
.
scaling
==
CPUInfo
::
Scaling
::
ENABLED
?
true
:
false
)
out
<<
indent
<<
FormatKV
(
"cpu_scaling_enabled"
,
info
.
scaling
==
CPUInfo
::
Scaling
::
ENABLED
?
true
:
false
)
<<
",
\n
"
;
<<
",
\n
"
;
}
}
...
@@ -139,8 +159,8 @@ bool JSONReporter::ReportContext(const Context& context) {
...
@@ -139,8 +159,8 @@ bool JSONReporter::ReportContext(const Context& context) {
out
<<
cache_indent
<<
FormatKV
(
"type"
,
CI
.
type
)
<<
",
\n
"
;
out
<<
cache_indent
<<
FormatKV
(
"type"
,
CI
.
type
)
<<
",
\n
"
;
out
<<
cache_indent
<<
FormatKV
(
"level"
,
static_cast
<
int64_t
>
(
CI
.
level
))
out
<<
cache_indent
<<
FormatKV
(
"level"
,
static_cast
<
int64_t
>
(
CI
.
level
))
<<
",
\n
"
;
<<
",
\n
"
;
out
<<
cache_indent
out
<<
cache_indent
<<
FormatKV
(
"size"
,
static_cast
<
int64_t
>
(
CI
.
size
))
<<
FormatKV
(
"size"
,
static_cast
<
int64_t
>
(
CI
.
size
))
<<
",
\n
"
;
<<
",
\n
"
;
out
<<
cache_indent
out
<<
cache_indent
<<
FormatKV
(
"num_sharing"
,
static_cast
<
int64_t
>
(
CI
.
num_sharing
))
<<
FormatKV
(
"num_sharing"
,
static_cast
<
int64_t
>
(
CI
.
num_sharing
))
<<
"
\n
"
;
<<
"
\n
"
;
...
@@ -162,13 +182,15 @@ bool JSONReporter::ReportContext(const Context& context) {
...
@@ -162,13 +182,15 @@ bool JSONReporter::ReportContext(const Context& context) {
#else
#else
const
char
build_type
[]
=
"debug"
;
const
char
build_type
[]
=
"debug"
;
#endif
#endif
out
<<
indent
<<
FormatKV
(
"library_build_type"
,
build_type
)
<<
"
\n
"
;
out
<<
indent
<<
FormatKV
(
"library_build_type"
,
build_type
);
if
(
internal
::
global_context
!=
nullptr
)
{
if
(
internal
::
global_context
!=
nullptr
)
{
for
(
const
auto
&
kv
:
*
internal
::
global_context
)
{
for
(
const
auto
&
kv
:
*
internal
::
global_context
)
{
out
<<
indent
<<
FormatKV
(
kv
.
first
,
kv
.
second
)
<<
"
\n
"
;
out
<<
",
\n
"
;
out
<<
indent
<<
FormatKV
(
kv
.
first
,
kv
.
second
);
}
}
}
}
out
<<
"
\n
"
;
// Close context block and open the list of benchmarks.
// Close context block and open the list of benchmarks.
out
<<
inner_indent
<<
"},
\n
"
;
out
<<
inner_indent
<<
"},
\n
"
;
...
...
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