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
680a399a
Commit
680a399a
authored
Mar 27, 2015
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add double-quotes where necessary
parent
71c41cde
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
csv_reporter.cc
src/csv_reporter.cc
+10
-2
string_util.cc
src/string_util.cc
+9
-0
string_util.h
src/string_util.h
+3
-0
No files found.
src/csv_reporter.cc
View file @
680a399a
...
...
@@ -22,6 +22,8 @@
#include "string_util.h"
#include "walltime.h"
// File format reference: http://edoceo.com/utilitas/csv-file-format.
namespace
benchmark
{
bool
CSVReporter
::
ReportContext
(
const
Context
&
context
)
{
...
...
@@ -71,7 +73,8 @@ void CSVReporter::PrintRunData(Run const& run) {
cpu_time
=
cpu_time
/
static_cast
<
double
>
(
run
.
iterations
);
}
std
::
cout
<<
run
.
benchmark_name
<<
","
;
// Field with embedded commas must be delimited with double-quotes.
std
::
cout
<<
"
\"
"
<<
run
.
benchmark_name
<<
"
\"
,"
;
std
::
cout
<<
run
.
iterations
<<
","
;
std
::
cout
<<
real_time
<<
","
;
std
::
cout
<<
cpu_time
<<
","
;
...
...
@@ -85,7 +88,12 @@ void CSVReporter::PrintRunData(Run const& run) {
}
std
::
cout
<<
","
;
if
(
!
run
.
report_label
.
empty
())
{
std
::
cout
<<
run
.
report_label
;
// Field with embedded double-quote characters must be doubled and the field
// delimited with double-quotes.
std
::
string
label
=
run
.
report_label
;
ReplaceAll
(
&
label
,
"
\"
"
,
"
\"\"
"
);
std
::
cout
<<
"
\"
"
<<
label
<<
"
\"
"
;
}
std
::
cout
<<
'\n'
;
}
...
...
src/string_util.cc
View file @
680a399a
...
...
@@ -154,4 +154,13 @@ std::string StringPrintF(const char* format, ...)
return
tmp
;
}
void
ReplaceAll
(
std
::
string
*
str
,
const
std
::
string
&
from
,
const
std
::
string
&
to
)
{
std
::
size_t
start
=
0
;
while
((
start
=
str
->
find
(
from
,
start
))
!=
std
::
string
::
npos
)
{
str
->
replace
(
start
,
from
.
length
(),
to
);
start
+=
to
.
length
();
}
}
}
// end namespace benchmark
src/string_util.h
View file @
680a399a
...
...
@@ -35,6 +35,9 @@ inline std::string StrCat(Args&&... args)
return
ss
.
str
();
}
void
ReplaceAll
(
std
::
string
*
str
,
const
std
::
string
&
from
,
const
std
::
string
&
to
);
}
// end namespace benchmark
#endif // BENCHMARK_STRING_UTIL_H_
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