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
12f1c5f4
Commit
12f1c5f4
authored
Mar 30, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add list test internals
parent
80514584
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
benchmark.cc
src/benchmark.cc
+29
-6
No files found.
src/benchmark.cc
View file @
12f1c5f4
...
@@ -37,6 +37,10 @@
...
@@ -37,6 +37,10 @@
#include "sysinfo.h"
#include "sysinfo.h"
#include "walltime.h"
#include "walltime.h"
DEFINE_bool
(
benchmark_list_tests
,
false
,
"Print a list of benchmarks. This option overrides all other "
"options."
);
DEFINE_string
(
benchmark_filter
,
"."
,
DEFINE_string
(
benchmark_filter
,
"."
,
"A regular expression that specifies the set of benchmarks "
"A regular expression that specifies the set of benchmarks "
"to execute. If this flag is empty, no benchmarks are run. "
"to execute. If this flag is empty, no benchmarks are run. "
...
@@ -370,7 +374,7 @@ bool BenchmarkFamilies::FindBenchmarks(
...
@@ -370,7 +374,7 @@ bool BenchmarkFamilies::FindBenchmarks(
MutexLock
l
(
mutex_
);
MutexLock
l
(
mutex_
);
for
(
BenchmarkImp
*
family
:
families_
)
{
for
(
BenchmarkImp
*
family
:
families_
)
{
// Family was deleted or benchmark doesn't match
// Family was deleted or benchmark doesn't match
if
(
family
==
nullptr
||
!
re
.
Match
(
family
->
name_
)
)
continue
;
if
(
family
==
nullptr
)
continue
;
if
(
family
->
arg_count_
==
-
1
)
{
if
(
family
->
arg_count_
==
-
1
)
{
family
->
arg_count_
=
0
;
family
->
arg_count_
=
0
;
...
@@ -414,7 +418,8 @@ bool BenchmarkFamilies::FindBenchmarks(
...
@@ -414,7 +418,8 @@ bool BenchmarkFamilies::FindBenchmarks(
instance
.
name
+=
StringPrintF
(
"/threads:%d"
,
instance
.
threads
);
instance
.
name
+=
StringPrintF
(
"/threads:%d"
,
instance
.
threads
);
}
}
benchmarks
->
push_back
(
instance
);
if
(
re
.
Match
(
instance
.
name
))
benchmarks
->
push_back
(
instance
);
}
}
}
}
}
}
...
@@ -766,19 +771,29 @@ void State::SetLabel(const char* label) {
...
@@ -766,19 +771,29 @@ void State::SetLabel(const char* label) {
}
}
namespace
internal
{
namespace
internal
{
namespace
{
void
PrintBenchmarkList
()
{
std
::
vector
<
Benchmark
::
Instance
>
benchmarks
;
auto
families
=
BenchmarkFamilies
::
GetInstance
();
if
(
!
families
->
FindBenchmarks
(
"."
,
&
benchmarks
))
return
;
for
(
const
internal
::
Benchmark
::
Instance
&
benchmark
:
benchmarks
)
std
::
cout
<<
benchmark
.
name
<<
"
\n
"
;
}
void
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
void
RunMatchingBenchmarks
(
const
std
::
string
&
spec
,
BenchmarkReporter
*
reporter
)
{
BenchmarkReporter
*
reporter
)
{
CHECK
(
reporter
!=
nullptr
);
CHECK
(
reporter
!=
nullptr
);
if
(
spec
.
empty
())
return
;
if
(
spec
.
empty
())
return
;
std
::
vector
<
benchmark
::
internal
::
Benchmark
::
Instance
>
benchmarks
;
std
::
vector
<
Benchmark
::
Instance
>
benchmarks
;
auto
families
=
benchmark
::
internal
::
BenchmarkFamilies
::
GetInstance
();
auto
families
=
BenchmarkFamilies
::
GetInstance
();
if
(
!
families
->
FindBenchmarks
(
spec
,
&
benchmarks
))
return
;
if
(
!
families
->
FindBenchmarks
(
spec
,
&
benchmarks
))
return
;
// Determine the width of the name field using a minimum width of 10.
// Determine the width of the name field using a minimum width of 10.
size_t
name_field_width
=
10
;
size_t
name_field_width
=
10
;
for
(
const
internal
::
Benchmark
::
Instance
&
benchmark
:
benchmarks
)
{
for
(
const
Benchmark
::
Instance
&
benchmark
:
benchmarks
)
{
name_field_width
=
name_field_width
=
std
::
max
<
size_t
>
(
name_field_width
,
benchmark
.
name
.
size
());
std
::
max
<
size_t
>
(
name_field_width
,
benchmark
.
name
.
size
());
}
}
...
@@ -814,6 +829,7 @@ std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
...
@@ -814,6 +829,7 @@ std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
}
}
}
}
}
// end namespace
}
// end namespace internal
}
// end namespace internal
void
RunSpecifiedBenchmarks
()
{
void
RunSpecifiedBenchmarks
()
{
...
@@ -821,6 +837,10 @@ void RunSpecifiedBenchmarks() {
...
@@ -821,6 +837,10 @@ void RunSpecifiedBenchmarks() {
}
}
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
)
{
void
RunSpecifiedBenchmarks
(
BenchmarkReporter
*
reporter
)
{
if
(
FLAGS_benchmark_list_tests
)
{
internal
::
PrintBenchmarkList
();
return
;
}
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
...
@@ -839,7 +859,8 @@ namespace internal {
...
@@ -839,7 +859,8 @@ namespace internal {
void
PrintUsageAndExit
()
{
void
PrintUsageAndExit
()
{
fprintf
(
stdout
,
fprintf
(
stdout
,
"benchmark"
"benchmark"
" [--benchmark_filter=<regex>]
\n
"
" [--benchmark_list_tests={true|false}]
\n
"
" [--benchmark_filter=<regex>]
\n
"
" [--benchmark_min_time=<min_time>]
\n
"
" [--benchmark_min_time=<min_time>]
\n
"
" [--benchmark_repetitions=<num_repetitions>]
\n
"
" [--benchmark_repetitions=<num_repetitions>]
\n
"
" [--benchmark_format=<tabular|json|csv>]
\n
"
" [--benchmark_format=<tabular|json|csv>]
\n
"
...
@@ -852,6 +873,8 @@ void ParseCommandLineFlags(int* argc, const char** argv) {
...
@@ -852,6 +873,8 @@ void ParseCommandLineFlags(int* argc, const char** argv) {
using
namespace
benchmark
;
using
namespace
benchmark
;
for
(
int
i
=
1
;
i
<
*
argc
;
++
i
)
{
for
(
int
i
=
1
;
i
<
*
argc
;
++
i
)
{
if
(
if
(
ParseBoolFlag
(
argv
[
i
],
"benchmark_list_tests"
,
&
FLAGS_benchmark_list_tests
)
||
ParseStringFlag
(
argv
[
i
],
"benchmark_filter"
,
ParseStringFlag
(
argv
[
i
],
"benchmark_filter"
,
&
FLAGS_benchmark_filter
)
||
&
FLAGS_benchmark_filter
)
||
ParseDoubleFlag
(
argv
[
i
],
"benchmark_min_time"
,
ParseDoubleFlag
(
argv
[
i
],
"benchmark_min_time"
,
...
...
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