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
e0de8171
Commit
e0de8171
authored
May 23, 2016
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change RunSpecifiedBenchmarks to return the number of benchmarks run. Fixes #145
parent
9fcdd6fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
17 deletions
+23
-17
benchmark_api.h
include/benchmark/benchmark_api.h
+8
-4
benchmark.cc
src/benchmark.cc
+11
-9
filter_test.cc
test/filter_test.cc
+4
-4
No files found.
include/benchmark/benchmark_api.h
View file @
e0de8171
...
...
@@ -160,10 +160,14 @@ class BenchmarkReporter;
void
Initialize
(
int
*
argc
,
char
**
argv
);
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
// and exit after running the benchmarks.
void
RunSpecifiedBenchmarks
();
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
);
// Run all benchmarks which match the specified --benchmark_filter flag.
// The second overload reports the results using the specified 'reporter'.
//
// RETURNS: The number of benchmarks run, not including repetitions. If
// '--benchmark_list_tests' is specified '0' is returned.
size_t
RunSpecifiedBenchmarks
();
size_t
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
);
// 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
...
...
src/benchmark.cc
View file @
e0de8171
...
...
@@ -863,14 +863,14 @@ void PrintBenchmarkList() {
}
}
void
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
BenchmarkReporter
*
reporter
)
{
size_t
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
BenchmarkReporter
*
reporter
)
{
CHECK
(
reporter
!=
nullptr
);
if
(
spec
.
empty
())
return
;
CHECK
(
!
spec
.
empty
())
;
std
::
vector
<
Benchmark
::
Instance
>
benchmarks
;
auto
families
=
BenchmarkFamilies
::
GetInstance
();
if
(
!
families
->
FindBenchmarks
(
spec
,
&
benchmarks
))
return
;
if
(
!
families
->
FindBenchmarks
(
spec
,
&
benchmarks
))
return
0
;
// Determine the width of the name field using a minimum width of 10.
size_t
name_field_width
=
10
;
...
...
@@ -894,6 +894,7 @@ void RunMatchingBenchmarks(const std::string& spec,
RunBenchmark
(
benchmark
,
reporter
);
}
}
return
benchmarks
.
size
();
}
std
::
unique_ptr
<
BenchmarkReporter
>
GetDefaultReporter
()
{
...
...
@@ -913,14 +914,14 @@ std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
}
// end namespace
}
// end namespace internal
void
RunSpecifiedBenchmarks
()
{
RunSpecifiedBenchmarks
(
nullptr
);
size_t
RunSpecifiedBenchmarks
()
{
return
RunSpecifiedBenchmarks
(
nullptr
);
}
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
)
{
size_t
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
)
{
if
(
FLAGS_benchmark_list_tests
)
{
internal
::
PrintBenchmarkList
();
return
;
return
0
;
}
std
::
string
spec
=
FLAGS_benchmark_filter
;
if
(
spec
.
empty
()
||
spec
==
"all"
)
...
...
@@ -931,8 +932,9 @@ void RunSpecifiedBenchmarks(BenchmarkReporter* reporter) {
default_reporter
=
internal
::
GetDefaultReporter
();
reporter
=
default_reporter
.
get
();
}
internal
::
RunMatchingBenchmarks
(
spec
,
reporter
);
size_t
num_run
=
internal
::
RunMatchingBenchmarks
(
spec
,
reporter
);
reporter
->
Finalize
();
return
num_run
;
}
namespace
internal
{
...
...
test/filter_test.cc
View file @
e0de8171
...
...
@@ -72,7 +72,7 @@ int main(int argc, char* argv[]) {
benchmark
::
Initialize
(
&
argc
,
argv
);
TestReporter
test_reporter
;
benchmark
::
RunSpecifiedBenchmarks
(
&
test_reporter
);
const
size_t
returned_count
=
benchmark
::
RunSpecifiedBenchmarks
(
&
test_reporter
);
if
(
argc
==
2
)
{
// Make sure we ran all of the tests
...
...
@@ -81,9 +81,9 @@ int main(int argc, char* argv[]) {
ss
>>
expected
;
const
size_t
count
=
test_reporter
.
GetCount
();
if
(
count
!=
expected
)
{
std
::
cerr
<<
"ERROR: Expected "
<<
expected
<<
" tests to be r
an but only
"
<<
count
<<
" completed"
<<
std
::
endl
;
if
(
count
!=
expected
||
returned_count
!=
expected
)
{
std
::
cerr
<<
"ERROR: Expected "
<<
expected
<<
" tests to be r
un but returned_count =
"
<<
returned_count
<<
" and reporter_count = "
<<
count
<<
std
::
endl
;
return
-
1
;
}
}
...
...
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