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
23861178
Commit
23861178
authored
Mar 17, 2015
by
Eric
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #99 from google/reporter_api_change
Apply reporter interface changes.
parents
b260cf76
20f1c0e2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
19 deletions
+28
-19
benchmark_api.h
include/benchmark/benchmark_api.h
+1
-1
reporter.h
include/benchmark/reporter.h
+11
-7
benchmark.cc
src/benchmark.cc
+7
-4
reporter.cc
src/reporter.cc
+7
-5
filter_test.cc
test/filter_test.cc
+2
-2
No files found.
include/benchmark/benchmark_api.h
View file @
23861178
...
@@ -149,7 +149,7 @@ void Initialize(int* argc, const char** argv);
...
@@ -149,7 +149,7 @@ void Initialize(int* argc, const char** argv);
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
// and exit after running the benchmarks.
// and exit after running the benchmarks.
void
RunSpecifiedBenchmarks
();
void
RunSpecifiedBenchmarks
();
void
RunSpecifiedBenchmarks
(
const
BenchmarkReporter
*
reporter
);
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
);
// If this routine is called, peak memory allocation past this point in the
// If this routine is called, peak memory allocation past this point in the
// benchmark is reported at the end of the benchmark report line. (It is
// benchmark is reported at the end of the benchmark report line. (It is
...
...
include/benchmark/reporter.h
View file @
23861178
...
@@ -67,13 +67,17 @@ class BenchmarkReporter {
...
@@ -67,13 +67,17 @@ class BenchmarkReporter {
// platform under which the benchmarks are running. The benchmark run is
// platform under which the benchmarks are running. The benchmark run is
// never started if this function returns false, allowing the reporter
// never started if this function returns false, allowing the reporter
// to skip runs based on the context information.
// to skip runs based on the context information.
virtual
bool
ReportContext
(
const
Context
&
context
)
const
=
0
;
virtual
bool
ReportContext
(
const
Context
&
context
)
=
0
;
// Called once for each group of benchmark runs, gives information about
// Called once for each group of benchmark runs, gives information about
// cpu-time and heap memory usage during the benchmark run.
// cpu-time and heap memory usage during the benchmark run.
// Note that all the grouped benchmark runs should refer to the same
// Note that all the grouped benchmark runs should refer to the same
// benchmark, thus have the same name.
// benchmark, thus have the same name.
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
report
)
const
=
0
;
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
report
)
=
0
;
// Called once and only once after ever group of benchmarks is run and
// reported.
virtual
void
Finalize
();
virtual
~
BenchmarkReporter
();
virtual
~
BenchmarkReporter
();
};
};
...
@@ -82,12 +86,12 @@ class BenchmarkReporter {
...
@@ -82,12 +86,12 @@ class BenchmarkReporter {
// default reporter used by RunSpecifiedBenchmarks().
// default reporter used by RunSpecifiedBenchmarks().
class
ConsoleReporter
:
public
BenchmarkReporter
{
class
ConsoleReporter
:
public
BenchmarkReporter
{
public
:
public
:
virtual
bool
ReportContext
(
const
Context
&
context
)
const
;
virtual
bool
ReportContext
(
const
Context
&
context
);
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
reports
)
const
;
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
reports
);
private
:
private
:
virtual
void
PrintRunData
(
const
Run
&
report
)
const
;
virtual
void
PrintRunData
(
const
Run
&
report
);
// TODO(ericwf): Find a better way to share this information.
mutable
size_t
name_field_width_
;
size_t
name_field_width_
;
};
};
}
// end namespace benchmark
}
// end namespace benchmark
...
...
src/benchmark.cc
View file @
23861178
...
@@ -606,7 +606,7 @@ void RunInThread(const benchmark::internal::Benchmark::Instance* b,
...
@@ -606,7 +606,7 @@ void RunInThread(const benchmark::internal::Benchmark::Instance* b,
}
}
void
RunBenchmark
(
const
benchmark
::
internal
::
Benchmark
::
Instance
&
b
,
void
RunBenchmark
(
const
benchmark
::
internal
::
Benchmark
::
Instance
&
b
,
const
BenchmarkReporter
*
br
)
EXCLUDES
(
GetBenchmarkLock
())
{
BenchmarkReporter
*
br
)
EXCLUDES
(
GetBenchmarkLock
())
{
int
iters
=
FLAGS_benchmark_iterations
?
FLAGS_benchmark_iterations
int
iters
=
FLAGS_benchmark_iterations
?
FLAGS_benchmark_iterations
:
1
;
:
1
;
std
::
vector
<
BenchmarkReporter
::
Run
>
reports
;
std
::
vector
<
BenchmarkReporter
::
Run
>
reports
;
...
@@ -763,7 +763,7 @@ void State::SetLabel(const char* label) {
...
@@ -763,7 +763,7 @@ void State::SetLabel(const char* label) {
namespace
internal
{
namespace
internal
{
void
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
void
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
const
BenchmarkReporter
*
reporter
)
{
BenchmarkReporter
*
reporter
)
{
CHECK
(
reporter
!=
nullptr
);
CHECK
(
reporter
!=
nullptr
);
if
(
spec
.
empty
())
return
;
if
(
spec
.
empty
())
return
;
...
@@ -813,12 +813,15 @@ void RunSpecifiedBenchmarks() {
...
@@ -813,12 +813,15 @@ void RunSpecifiedBenchmarks() {
RunSpecifiedBenchmarks
(
nullptr
);
RunSpecifiedBenchmarks
(
nullptr
);
}
}
void
RunSpecifiedBenchmarks
(
const
BenchmarkReporter
*
reporter
)
{
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
provided_
reporter
)
{
std
::
string
spec
=
FLAGS_benchmark_filter
;
std
::
string
spec
=
FLAGS_benchmark_filter
;
if
(
spec
.
empty
()
||
spec
==
"all"
)
if
(
spec
.
empty
()
||
spec
==
"all"
)
spec
=
"."
;
// Regexp that matches all benchmarks
spec
=
"."
;
// Regexp that matches all benchmarks
ConsoleReporter
default_reporter
;
ConsoleReporter
default_reporter
;
internal
::
RunMatchingBenchmarks
(
spec
,
reporter
?
reporter
:
&
default_reporter
);
BenchmarkReporter
*
reporter
=
provided_reporter
?
provided_reporter
:
&
default_reporter
;
internal
::
RunMatchingBenchmarks
(
spec
,
reporter
);
reporter
->
Finalize
();
}
}
namespace
internal
{
namespace
internal
{
...
...
src/reporter.cc
View file @
23861178
...
@@ -85,10 +85,13 @@ void ComputeStats(const std::vector<BenchmarkReporter::Run>& reports,
...
@@ -85,10 +85,13 @@ void ComputeStats(const std::vector<BenchmarkReporter::Run>& reports,
}
// end namespace
}
// end namespace
void
BenchmarkReporter
::
Finalize
()
{
}
BenchmarkReporter
::~
BenchmarkReporter
()
{}
BenchmarkReporter
::~
BenchmarkReporter
()
{
}
bool
ConsoleReporter
::
ReportContext
(
const
Context
&
context
)
const
{
bool
ConsoleReporter
::
ReportContext
(
const
Context
&
context
)
{
name_field_width_
=
context
.
name_field_width
;
name_field_width_
=
context
.
name_field_width
;
fprintf
(
stdout
,
fprintf
(
stdout
,
...
@@ -125,8 +128,7 @@ bool ConsoleReporter::ReportContext(const Context& context) const {
...
@@ -125,8 +128,7 @@ bool ConsoleReporter::ReportContext(const Context& context) const {
return
true
;
return
true
;
}
}
void
ConsoleReporter
::
ReportRuns
(
void
ConsoleReporter
::
ReportRuns
(
const
std
::
vector
<
Run
>&
reports
)
{
const
std
::
vector
<
Run
>&
reports
)
const
{
if
(
reports
.
empty
())
{
if
(
reports
.
empty
())
{
return
;
return
;
}
}
...
@@ -151,7 +153,7 @@ void ConsoleReporter::ReportRuns(
...
@@ -151,7 +153,7 @@ void ConsoleReporter::ReportRuns(
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
"
\n
"
);
}
}
void
ConsoleReporter
::
PrintRunData
(
const
Run
&
result
)
const
{
void
ConsoleReporter
::
PrintRunData
(
const
Run
&
result
)
{
// Format bytes per second
// Format bytes per second
std
::
string
rate
;
std
::
string
rate
;
if
(
result
.
bytes_per_second
>
0
)
{
if
(
result
.
bytes_per_second
>
0
)
{
...
...
test/filter_test.cc
View file @
23861178
...
@@ -23,11 +23,11 @@ double CalculatePi(int depth) {
...
@@ -23,11 +23,11 @@ double CalculatePi(int depth) {
class
TestReporter
:
public
benchmark
::
ConsoleReporter
{
class
TestReporter
:
public
benchmark
::
ConsoleReporter
{
public
:
public
:
virtual
bool
ReportContext
(
const
Context
&
context
)
const
{
virtual
bool
ReportContext
(
const
Context
&
context
)
{
return
ConsoleReporter
::
ReportContext
(
context
);
return
ConsoleReporter
::
ReportContext
(
context
);
};
};
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
report
)
const
{
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
report
)
{
++
count_
;
++
count_
;
ConsoleReporter
::
ReportRuns
(
report
);
ConsoleReporter
::
ReportRuns
(
report
);
};
};
...
...
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