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
d32c5c64
Commit
d32c5c64
authored
Aug 19, 2014
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #47 from mattyclarkson/benchmark_test
Make sure all benchmark tests run
parents
b1041fc3
11769369
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
3 deletions
+43
-3
.gitignore
.gitignore
+1
-0
GetGitVersion.cmake
cmake/GetGitVersion.cmake
+1
-1
CMakeLists.txt
test/CMakeLists.txt
+6
-1
benchmark_test.cc
test/benchmark_test.cc
+35
-1
No files found.
.gitignore
View file @
d32c5c64
...
...
@@ -7,6 +7,7 @@
*~
/test/benchmark_test
/test/re_test
/Testing
CMakeCache.txt
CMakeFiles/
Makefile
...
...
cmake/GetGitVersion.cmake
View file @
d32c5c64
...
...
@@ -38,7 +38,7 @@ function(get_git_version var)
ERROR_QUIET
)
string
(
COMPARE NOTEQUAL
"
${
GIT_DIFF_INDEX
}
"
""
GIT_DIRTY
)
if
(
${
GIT_DIRTY
}
)
s
tring
(
CONCAT GIT_VERSION
${
GIT_VERSION
}
"
-dirty"
)
s
et
(
GIT_VERSION
"
${
GIT_VERSION
}
-dirty"
)
endif
()
message
(
"-- git Version:
${
GIT_VERSION
}
"
)
set
(
${
var
}
${
GIT_VERSION
}
PARENT_SCOPE
)
...
...
test/CMakeLists.txt
View file @
d32c5c64
# Demonstration executable
add_executable
(
benchmark_test benchmark_test.cc
)
target_link_libraries
(
benchmark_test benchmark
${
CMAKE_THREAD_LIBS_INIT
}
)
add_test
(
benchmark benchmark_test
)
add_test
(
benchmark benchmark_test 50
)
add_test
(
benchmark_filter_simple benchmark_test --benchmark_filter=Calculate 16
)
add_test
(
benchmark_filter_prefix benchmark_test --benchmark_filter=*Calculate 0
)
add_test
(
benchmark_filter_suffix benchmark_test --benchmark_filter=Calculate* 16
)
add_test
(
benchmark_filter_both benchmark_test --benchmark_filter=*Calculate* 0
)
add_test
(
benchmark_filter_regex_wildcard benchmark_test --benchmark_filter=.*Calculate.* 16
)
# Test harness for regex wrapper
add_executable
(
re_test
${
RE_FILES
}
"re_test.cc"
)
...
...
test/benchmark_test.cc
View file @
d32c5c64
...
...
@@ -10,6 +10,7 @@
#include <mutex>
#include <set>
#include <sstream>
#include <string>
#include <vector>
namespace
{
...
...
@@ -141,12 +142,45 @@ static void BM_LongTest(benchmark::State& state) {
}
BENCHMARK
(
BM_LongTest
)
->
Range
(
1
<<
16
,
1
<<
28
);
class
TestReporter
:
public
benchmark
::
internal
::
ConsoleReporter
{
public
:
virtual
bool
ReportContext
(
const
Context
&
context
)
const
{
return
ConsoleReporter
::
ReportContext
(
context
);
};
virtual
void
ReportRuns
(
const
std
::
vector
<
Run
>&
report
)
const
{
++
count_
;
ConsoleReporter
::
ReportRuns
(
report
);
};
TestReporter
()
:
count_
(
0
)
{}
virtual
~
TestReporter
()
{}
int
GetCount
()
const
{
return
count_
;
}
private
:
mutable
size_t
count_
;
};
int
main
(
int
argc
,
const
char
*
argv
[])
{
benchmark
::
Initialize
(
&
argc
,
argv
);
CHECK
(
Factorial
(
8
)
==
40320
);
CHECK
(
CalculatePi
(
1
)
==
0.0
);
benchmark
::
RunSpecifiedBenchmarks
();
TestReporter
test_reporter
;
benchmark
::
RunSpecifiedBenchmarks
(
&
test_reporter
);
// Make sure we ran all of the tests
const
size_t
count
=
test_reporter
.
GetCount
();
const
size_t
expected
=
(
argc
==
2
)
?
std
::
stoul
(
argv
[
1
])
:
count
;
if
(
count
!=
expected
)
{
std
::
cerr
<<
"ERROR: Expected "
<<
expected
<<
" tests to be ran but only "
<<
count
<<
" completed"
<<
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