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
5f9823bd
Commit
5f9823bd
authored
May 23, 2016
by
Ismael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed non-const reference arguments
parent
8afbf0ed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
45 deletions
+45
-45
reporter.h
include/benchmark/reporter.h
+4
-4
console_reporter.cc
src/console_reporter.cc
+6
-6
csv_reporter.cc
src/csv_reporter.cc
+2
-2
json_reporter.cc
src/json_reporter.cc
+2
-2
reporter.cc
src/reporter.cc
+31
-31
No files found.
include/benchmark/reporter.h
View file @
5f9823bd
...
@@ -52,7 +52,7 @@ class BenchmarkReporter {
...
@@ -52,7 +52,7 @@ class BenchmarkReporter {
complexity
(
O_None
),
complexity
(
O_None
),
arg1
(
0
),
arg1
(
0
),
arg2
(
0
),
arg2
(
0
),
report_big
O
(
false
),
report_big
_o
(
false
),
report_rms
(
false
)
{}
report_rms
(
false
)
{}
std
::
string
benchmark_name
;
std
::
string
benchmark_name
;
...
@@ -75,7 +75,7 @@ class BenchmarkReporter {
...
@@ -75,7 +75,7 @@ class BenchmarkReporter {
int
arg2
;
int
arg2
;
// Inform print function whether the current run is a complexity report
// Inform print function whether the current run is a complexity report
bool
report_big
O
;
bool
report_big
_o
;
bool
report_rms
;
bool
report_rms
;
};
};
...
@@ -105,8 +105,8 @@ class BenchmarkReporter {
...
@@ -105,8 +105,8 @@ class BenchmarkReporter {
virtual
~
BenchmarkReporter
();
virtual
~
BenchmarkReporter
();
protected
:
protected
:
static
void
ComputeStats
(
const
std
::
vector
<
Run
>
&
reports
,
Run
&
mean
,
Run
&
stddev
);
static
void
ComputeStats
(
const
std
::
vector
<
Run
>
&
reports
,
Run
*
mean
,
Run
*
stddev
);
static
void
ComputeBigO
(
const
std
::
vector
<
Run
>
&
reports
,
Run
&
bigO
,
Run
&
rms
);
static
void
ComputeBigO
(
const
std
::
vector
<
Run
>
&
reports
,
Run
*
bigO
,
Run
*
rms
);
static
TimeUnitMultiplier
GetTimeUnitAndMultiplier
(
TimeUnit
unit
);
static
TimeUnitMultiplier
GetTimeUnitAndMultiplier
(
TimeUnit
unit
);
static
std
::
string
GetBigO
(
BigO
complexity
);
static
std
::
string
GetBigO
(
BigO
complexity
);
};
};
...
...
src/console_reporter.cc
View file @
5f9823bd
...
@@ -72,7 +72,7 @@ void ConsoleReporter::ReportRuns(const std::vector<Run>& reports) {
...
@@ -72,7 +72,7 @@ void ConsoleReporter::ReportRuns(const std::vector<Run>& reports) {
Run
mean_data
;
Run
mean_data
;
Run
stddev_data
;
Run
stddev_data
;
BenchmarkReporter
::
ComputeStats
(
reports
,
mean_data
,
stddev_data
);
BenchmarkReporter
::
ComputeStats
(
reports
,
&
mean_data
,
&
stddev_data
);
// Output using PrintRun.
// Output using PrintRun.
PrintRunData
(
mean_data
);
PrintRunData
(
mean_data
);
...
@@ -85,12 +85,12 @@ void ConsoleReporter::ReportComplexity(const std::vector<Run> & complexity_repor
...
@@ -85,12 +85,12 @@ void ConsoleReporter::ReportComplexity(const std::vector<Run> & complexity_repor
return
;
return
;
}
}
Run
big
O
_data
;
Run
big
_o
_data
;
Run
rms_data
;
Run
rms_data
;
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
bigO_data
,
rms_data
);
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
&
big_o_data
,
&
rms_data
);
// Output using PrintRun.
// Output using PrintRun.
PrintRunData
(
big
O
_data
);
PrintRunData
(
big
_o
_data
);
PrintRunData
(
rms_data
);
PrintRunData
(
rms_data
);
}
}
...
@@ -115,8 +115,8 @@ void ConsoleReporter::PrintRunData(const Run& result) {
...
@@ -115,8 +115,8 @@ void ConsoleReporter::PrintRunData(const Run& result) {
ColorPrintf
(
COLOR_GREEN
,
"%-*s "
,
ColorPrintf
(
COLOR_GREEN
,
"%-*s "
,
name_field_width_
,
result
.
benchmark_name
.
c_str
());
name_field_width_
,
result
.
benchmark_name
.
c_str
());
if
(
result
.
report_big
O
)
{
if
(
result
.
report_big
_o
)
{
std
::
string
big_o
=
result
.
report_big
O
?
GetBigO
(
result
.
complexity
)
:
""
;
std
::
string
big_o
=
result
.
report_big
_o
?
GetBigO
(
result
.
complexity
)
:
""
;
ColorPrintf
(
COLOR_YELLOW
,
"%10.4f %s %10.4f %s "
,
ColorPrintf
(
COLOR_YELLOW
,
"%10.4f %s %10.4f %s "
,
result
.
real_accumulated_time
*
multiplier
,
result
.
real_accumulated_time
*
multiplier
,
big_o
.
c_str
(),
big_o
.
c_str
(),
...
...
src/csv_reporter.cc
View file @
5f9823bd
...
@@ -57,7 +57,7 @@ void CSVReporter::ReportRuns(const std::vector<Run> & reports) {
...
@@ -57,7 +57,7 @@ void CSVReporter::ReportRuns(const std::vector<Run> & reports) {
if
(
reports
.
size
()
>=
2
)
{
if
(
reports
.
size
()
>=
2
)
{
Run
mean_data
;
Run
mean_data
;
Run
stddev_data
;
Run
stddev_data
;
BenchmarkReporter
::
ComputeStats
(
reports
,
mean_data
,
stddev_data
);
BenchmarkReporter
::
ComputeStats
(
reports
,
&
mean_data
,
&
stddev_data
);
reports_cp
.
push_back
(
mean_data
);
reports_cp
.
push_back
(
mean_data
);
reports_cp
.
push_back
(
stddev_data
);
reports_cp
.
push_back
(
stddev_data
);
}
}
...
@@ -74,7 +74,7 @@ void CSVReporter::ReportComplexity(const std::vector<Run> & complexity_reports)
...
@@ -74,7 +74,7 @@ void CSVReporter::ReportComplexity(const std::vector<Run> & complexity_reports)
Run
bigO_data
;
Run
bigO_data
;
Run
rms_data
;
Run
rms_data
;
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
bigO_data
,
rms_data
);
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
&
bigO_data
,
&
rms_data
);
// Output using PrintRun.
// Output using PrintRun.
PrintRunData
(
bigO_data
);
PrintRunData
(
bigO_data
);
...
...
src/json_reporter.cc
View file @
5f9823bd
...
@@ -100,7 +100,7 @@ void JSONReporter::ReportRuns(std::vector<Run> const& reports) {
...
@@ -100,7 +100,7 @@ void JSONReporter::ReportRuns(std::vector<Run> const& reports) {
if
(
reports
.
size
()
>=
2
)
{
if
(
reports
.
size
()
>=
2
)
{
Run
mean_data
;
Run
mean_data
;
Run
stddev_data
;
Run
stddev_data
;
BenchmarkReporter
::
ComputeStats
(
reports
,
mean_data
,
stddev_data
);
BenchmarkReporter
::
ComputeStats
(
reports
,
&
mean_data
,
&
stddev_data
);
reports_cp
.
push_back
(
mean_data
);
reports_cp
.
push_back
(
mean_data
);
reports_cp
.
push_back
(
stddev_data
);
reports_cp
.
push_back
(
stddev_data
);
}
}
...
@@ -129,7 +129,7 @@ void JSONReporter::ReportComplexity(const std::vector<Run> & complexity_reports)
...
@@ -129,7 +129,7 @@ void JSONReporter::ReportComplexity(const std::vector<Run> & complexity_reports)
Run
bigO_data
;
Run
bigO_data
;
Run
rms_data
;
Run
rms_data
;
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
bigO_data
,
rms_data
);
BenchmarkReporter
::
ComputeBigO
(
complexity_reports
,
&
bigO_data
,
&
rms_data
);
// Output using PrintRun.
// Output using PrintRun.
out
<<
indent
<<
"{
\n
"
;
out
<<
indent
<<
"{
\n
"
;
...
...
src/reporter.cc
View file @
5f9823bd
...
@@ -26,7 +26,7 @@ namespace benchmark {
...
@@ -26,7 +26,7 @@ namespace benchmark {
void
BenchmarkReporter
::
ComputeStats
(
void
BenchmarkReporter
::
ComputeStats
(
const
std
::
vector
<
Run
>&
reports
,
const
std
::
vector
<
Run
>&
reports
,
Run
&
mean_data
,
Run
&
stddev_data
)
{
Run
*
mean_data
,
Run
*
stddev_data
)
{
CHECK
(
reports
.
size
()
>=
2
)
<<
"Cannot compute stats for less than 2 reports"
;
CHECK
(
reports
.
size
()
>=
2
)
<<
"Cannot compute stats for less than 2 reports"
;
// Accumulators.
// Accumulators.
Stat1_d
real_accumulated_time_stat
;
Stat1_d
real_accumulated_time_stat
;
...
@@ -50,38 +50,38 @@ void BenchmarkReporter::ComputeStats(
...
@@ -50,38 +50,38 @@ void BenchmarkReporter::ComputeStats(
}
}
// Get the data from the accumulator to BenchmarkReporter::Run's.
// Get the data from the accumulator to BenchmarkReporter::Run's.
mean_data
.
benchmark_name
=
reports
[
0
].
benchmark_name
+
"_mean"
;
mean_data
->
benchmark_name
=
reports
[
0
].
benchmark_name
+
"_mean"
;
mean_data
.
iterations
=
run_iterations
;
mean_data
->
iterations
=
run_iterations
;
mean_data
.
real_accumulated_time
=
real_accumulated_time_stat
.
Mean
()
*
mean_data
->
real_accumulated_time
=
real_accumulated_time_stat
.
Mean
()
*
run_iterations
;
run_iterations
;
mean_data
.
cpu_accumulated_time
=
cpu_accumulated_time_stat
.
Mean
()
*
mean_data
->
cpu_accumulated_time
=
cpu_accumulated_time_stat
.
Mean
()
*
run_iterations
;
run_iterations
;
mean_data
.
bytes_per_second
=
bytes_per_second_stat
.
Mean
();
mean_data
->
bytes_per_second
=
bytes_per_second_stat
.
Mean
();
mean_data
.
items_per_second
=
items_per_second_stat
.
Mean
();
mean_data
->
items_per_second
=
items_per_second_stat
.
Mean
();
// Only add label to mean/stddev if it is same for all runs
// Only add label to mean/stddev if it is same for all runs
mean_data
.
report_label
=
reports
[
0
].
report_label
;
mean_data
->
report_label
=
reports
[
0
].
report_label
;
for
(
std
::
size_t
i
=
1
;
i
<
reports
.
size
();
i
++
)
{
for
(
std
::
size_t
i
=
1
;
i
<
reports
.
size
();
i
++
)
{
if
(
reports
[
i
].
report_label
!=
reports
[
0
].
report_label
)
{
if
(
reports
[
i
].
report_label
!=
reports
[
0
].
report_label
)
{
mean_data
.
report_label
=
""
;
mean_data
->
report_label
=
""
;
break
;
break
;
}
}
}
}
stddev_data
.
benchmark_name
=
reports
[
0
].
benchmark_name
+
"_stddev"
;
stddev_data
->
benchmark_name
=
reports
[
0
].
benchmark_name
+
"_stddev"
;
stddev_data
.
report_label
=
mean_data
.
report_label
;
stddev_data
->
report_label
=
mean_data
->
report_label
;
stddev_data
.
iterations
=
0
;
stddev_data
->
iterations
=
0
;
stddev_data
.
real_accumulated_time
=
stddev_data
->
real_accumulated_time
=
real_accumulated_time_stat
.
StdDev
();
real_accumulated_time_stat
.
StdDev
();
stddev_data
.
cpu_accumulated_time
=
stddev_data
->
cpu_accumulated_time
=
cpu_accumulated_time_stat
.
StdDev
();
cpu_accumulated_time_stat
.
StdDev
();
stddev_data
.
bytes_per_second
=
bytes_per_second_stat
.
StdDev
();
stddev_data
->
bytes_per_second
=
bytes_per_second_stat
.
StdDev
();
stddev_data
.
items_per_second
=
items_per_second_stat
.
StdDev
();
stddev_data
->
items_per_second
=
items_per_second_stat
.
StdDev
();
}
}
void
BenchmarkReporter
::
ComputeBigO
(
void
BenchmarkReporter
::
ComputeBigO
(
const
std
::
vector
<
Run
>&
reports
,
const
std
::
vector
<
Run
>&
reports
,
Run
&
bigO
,
Run
&
rms
)
{
Run
*
big_o
,
Run
*
rms
)
{
CHECK
(
reports
.
size
()
>=
2
)
<<
"Cannot compute asymptotic complexity for less than 2 reports"
;
CHECK
(
reports
.
size
()
>=
2
)
<<
"Cannot compute asymptotic complexity for less than 2 reports"
;
// Accumulators.
// Accumulators.
std
::
vector
<
int
>
N
;
std
::
vector
<
int
>
N
;
...
@@ -106,26 +106,26 @@ void BenchmarkReporter::ComputeBigO(
...
@@ -106,26 +106,26 @@ void BenchmarkReporter::ComputeBigO(
std
::
string
benchmark_name
=
reports
[
0
].
benchmark_name
.
substr
(
0
,
reports
[
0
].
benchmark_name
.
find
(
'/'
));
std
::
string
benchmark_name
=
reports
[
0
].
benchmark_name
.
substr
(
0
,
reports
[
0
].
benchmark_name
.
find
(
'/'
));
// Get the data from the accumulator to BenchmarkReporter::Run's.
// Get the data from the accumulator to BenchmarkReporter::Run's.
big
O
.
benchmark_name
=
benchmark_name
+
"_BigO"
;
big
_o
->
benchmark_name
=
benchmark_name
+
"_BigO"
;
big
O
.
iterations
=
0
;
big
_o
->
iterations
=
0
;
big
O
.
real_accumulated_time
=
resultReal
.
coef
;
big
_o
->
real_accumulated_time
=
resultReal
.
coef
;
big
O
.
cpu_accumulated_time
=
resultCpu
.
coef
;
big
_o
->
cpu_accumulated_time
=
resultCpu
.
coef
;
big
O
.
report_bigO
=
true
;
big
_o
->
report_big_o
=
true
;
big
O
.
complexity
=
resultCpu
.
complexity
;
big
_o
->
complexity
=
resultCpu
.
complexity
;
double
multiplier
;
double
multiplier
;
const
char
*
timeLabel
;
const
char
*
timeLabel
;
std
::
tie
(
timeLabel
,
multiplier
)
=
GetTimeUnitAndMultiplier
(
reports
[
0
].
time_unit
);
std
::
tie
(
timeLabel
,
multiplier
)
=
GetTimeUnitAndMultiplier
(
reports
[
0
].
time_unit
);
// Only add label to mean/stddev if it is same for all runs
// Only add label to mean/stddev if it is same for all runs
big
O
.
report_label
=
reports
[
0
].
report_label
;
big
_o
->
report_label
=
reports
[
0
].
report_label
;
rms
.
benchmark_name
=
benchmark_name
+
"_RMS"
;
rms
->
benchmark_name
=
benchmark_name
+
"_RMS"
;
rms
.
report_label
=
bigO
.
report_label
;
rms
->
report_label
=
big_o
->
report_label
;
rms
.
iterations
=
0
;
rms
->
iterations
=
0
;
rms
.
real_accumulated_time
=
resultReal
.
rms
/
multiplier
;
rms
->
real_accumulated_time
=
resultReal
.
rms
/
multiplier
;
rms
.
cpu_accumulated_time
=
resultCpu
.
rms
/
multiplier
;
rms
->
cpu_accumulated_time
=
resultCpu
.
rms
/
multiplier
;
rms
.
report_rms
=
true
;
rms
->
report_rms
=
true
;
rms
.
complexity
=
resultCpu
.
complexity
;
rms
->
complexity
=
resultCpu
.
complexity
;
}
}
std
::
string
BenchmarkReporter
::
GetBigO
(
BigO
complexity
)
{
std
::
string
BenchmarkReporter
::
GetBigO
(
BigO
complexity
)
{
...
...
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