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
daa8a67a
Commit
daa8a67a
authored
Mar 18, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add C++03 test and update README
parent
38066e8b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
2 deletions
+59
-2
CMakeLists.txt
CMakeLists.txt
+2
-2
README.md
README.md
+12
-0
CMakeLists.txt
test/CMakeLists.txt
+10
-0
benchmark_test.cc
test/benchmark_test.cc
+4
-0
cxx03_test.cc
test/cxx03_test.cc
+31
-0
No files found.
CMakeLists.txt
View file @
daa8a67a
...
@@ -27,9 +27,9 @@ include(CXXFeatureCheck)
...
@@ -27,9 +27,9 @@ include(CXXFeatureCheck)
check_cxx_compiler_flag
(
-std=c++11 HAVE_FLAG_CXX_11
)
check_cxx_compiler_flag
(
-std=c++11 HAVE_FLAG_CXX_11
)
check_cxx_compiler_flag
(
-std=c++0x HAVE_FLAG_CXX_0X
)
check_cxx_compiler_flag
(
-std=c++0x HAVE_FLAG_CXX_0X
)
if
(
HAVE_FLAG_CXX_11
)
if
(
HAVE_FLAG_CXX_11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
list
(
APPEND CMAKE_CXX_FLAGS -std=c++11
)
elseif
(
HAVE_FLAG_CXX_0X
)
elseif
(
HAVE_FLAG_CXX_0X
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++0x"
)
list
(
APPEND CMAKE_CXX_FLAGS -std=c++0x
)
endif
()
endif
()
# Turn compiler warnings up to 11
# Turn compiler warnings up to 11
...
...
README.md
View file @
daa8a67a
...
@@ -130,6 +130,18 @@ template <class Q> int BM_Sequential(benchmark::State& state) {
...
@@ -130,6 +130,18 @@ template <class Q> int BM_Sequential(benchmark::State& state) {
BENCHMARK_TEMPLATE
(
BM_Sequential
,
WaitQueue
<
int
>
)
->
Range
(
1
<<
0
,
1
<<
10
);
BENCHMARK_TEMPLATE
(
BM_Sequential
,
WaitQueue
<
int
>
)
->
Range
(
1
<<
0
,
1
<<
10
);
```
```
Three macros are provided for adding benchmark templates.
```
c++
#if __cplusplus >= 201103L // C++11 and greater.
#define BENCHMARK_TEMPLATE(func, ...) // Takes any number of parameters.
#else // C++ < C++11
#define BENCHMARK_TEMPLATE(func, arg1)
#endif
#define BENCHMARK_TEMPLATE1(func, arg1)
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
```
In a multithreaded test, it is guaranteed that none of the threads will start
In a multithreaded test, it is guaranteed that none of the threads will start
until all have called KeepRunning, and all will have finished before KeepRunning
until all have called KeepRunning, and all will have finished before KeepRunning
returns false. As such, any global setup or teardown you want to do can be
returns false. As such, any global setup or teardown you want to do can be
...
...
test/CMakeLists.txt
View file @
daa8a67a
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
set
(
CXX03_FLAGS
"
${
CMAKE_CXX_FLAGS
}
"
)
list
(
REMOVE_ITEM CXX03_FLAGS -std=c++11 -std=c++0x
)
list
(
APPEND CXX03_FLAGS -std=c++03
)
string
(
REPLACE
";"
" "
CXX03_FLAGS
"
${
CXX03_FLAGS
}
"
)
macro
(
compile_benchmark_test name
)
macro
(
compile_benchmark_test name
)
add_executable
(
${
name
}
"
${
name
}
.cc"
)
add_executable
(
${
name
}
"
${
name
}
.cc"
)
target_link_libraries
(
${
name
}
benchmark
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
${
name
}
benchmark
${
CMAKE_THREAD_LIBS_INIT
}
)
...
@@ -23,3 +28,8 @@ add_test(filter_regex_end filter_test --benchmark_filter=.*Pi$ 8)
...
@@ -23,3 +28,8 @@ add_test(filter_regex_end filter_test --benchmark_filter=.*Pi$ 8)
compile_benchmark_test
(
basic_test
)
compile_benchmark_test
(
basic_test
)
add_test
(
basic basic_test
)
add_test
(
basic basic_test
)
compile_benchmark_test
(
cxx03_test
)
set_target_properties
(
cxx03_test
PROPERTIES COMPILE_FLAGS
"
${
CXX03_FLAGS
}
"
)
add_test
(
cxx03 cxx03_test
)
test/benchmark_test.cc
View file @
daa8a67a
...
@@ -121,6 +121,10 @@ static void BM_Sequential(benchmark::State& state) {
...
@@ -121,6 +121,10 @@ static void BM_Sequential(benchmark::State& state) {
}
}
BENCHMARK_TEMPLATE2
(
BM_Sequential
,
std
::
vector
<
int
>
,
int
)
->
Range
(
1
<<
0
,
1
<<
10
);
BENCHMARK_TEMPLATE2
(
BM_Sequential
,
std
::
vector
<
int
>
,
int
)
->
Range
(
1
<<
0
,
1
<<
10
);
BENCHMARK_TEMPLATE
(
BM_Sequential
,
std
::
list
<
int
>
)
->
Range
(
1
<<
0
,
1
<<
10
);
BENCHMARK_TEMPLATE
(
BM_Sequential
,
std
::
list
<
int
>
)
->
Range
(
1
<<
0
,
1
<<
10
);
// Test the variadic version of BENCHMARK_TEMPLATE in C++11 and beyond.
#if __cplusplus >= 201103L
BENCHMARK_TEMPLATE
(
BM_Sequential
,
std
::
vector
<
int
>
,
int
)
->
Arg
(
512
);
#endif
static
void
BM_StringCompare
(
benchmark
::
State
&
state
)
{
static
void
BM_StringCompare
(
benchmark
::
State
&
state
)
{
std
::
string
s1
(
state
.
range_x
(),
'-'
);
std
::
string
s1
(
state
.
range_x
(),
'-'
);
...
...
test/cxx03_test.cc
0 → 100644
View file @
daa8a67a
#include <cstddef>
#include "benchmark/benchmark.h"
#if __cplusplus >= 201103L
#error C++11 or greater detected. Should be C++03.
#endif
void
BM_empty
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
volatile
std
::
size_t
x
=
state
.
iterations
();
((
void
)
x
);
}
}
BENCHMARK
(
BM_empty
);
template
<
class
T
,
class
U
>
void
BM_template2
(
benchmark
::
State
&
state
)
{
BM_empty
(
state
);
}
BENCHMARK_TEMPLATE2
(
BM_template2
,
int
,
long
);
template
<
class
T
>
void
BM_template1
(
benchmark
::
State
&
state
)
{
BM_empty
(
state
);
}
BENCHMARK_TEMPLATE
(
BM_template1
,
long
);
BENCHMARK_TEMPLATE1
(
BM_template1
,
int
);
BENCHMARK_MAIN
()
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