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
c69b385c
Commit
c69b385c
authored
May 02, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add first unit test for benchmark_tabular_counters.
parent
17a012d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
+71
-0
CMakeLists.txt
test/CMakeLists.txt
+3
-0
user_counters_tabular_test.cc
test/user_counters_tabular_test.cc
+68
-0
No files found.
test/CMakeLists.txt
View file @
c69b385c
...
@@ -95,6 +95,9 @@ add_test(reporter_output_test reporter_output_test --benchmark_min_time=0.01)
...
@@ -95,6 +95,9 @@ add_test(reporter_output_test reporter_output_test --benchmark_min_time=0.01)
compile_output_test
(
user_counters_test
)
compile_output_test
(
user_counters_test
)
add_test
(
user_counters_test user_counters_test --benchmark_min_time=0.01
)
add_test
(
user_counters_test user_counters_test --benchmark_min_time=0.01
)
compile_output_test
(
user_counters_tabular_test
)
add_test
(
user_counters_tabular_test user_counters_tabular_test --benchmark_counters_tabular=true --benchmark_min_time=0.01
)
check_cxx_compiler_flag
(
-std=c++03 BENCHMARK_HAS_CXX03_FLAG
)
check_cxx_compiler_flag
(
-std=c++03 BENCHMARK_HAS_CXX03_FLAG
)
if
(
BENCHMARK_HAS_CXX03_FLAG
)
if
(
BENCHMARK_HAS_CXX03_FLAG
)
set
(
CXX03_FLAGS
"
${
CMAKE_CXX_FLAGS
}
"
)
set
(
CXX03_FLAGS
"
${
CMAKE_CXX_FLAGS
}
"
)
...
...
test/user_counters_tabular_test.cc
0 → 100644
View file @
c69b385c
#undef NDEBUG
#include "benchmark/benchmark.h"
#include "output_test.h"
// ========================================================================= //
// ---------------------- Testing Prologue Output -------------------------- //
// ========================================================================= //
ADD_CASES
(
TC_ConsoleOut
,
{{
"^[-]+$"
,
MR_Next
},
{
"^Benchmark %s Time %s CPU %s Iterations %s Bar %s Bat %s Baz %s Foo %s Frob %s Lob$"
,
MR_Next
},
{
"^[-]+$"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"%csv_header,
\"
Bar
\"
,
\"
Bat
\"
,
\"
Baz
\"
,
\"
Foo
\"
,
\"
Frob
\"
,
\"
Lob
\"
"
}});
// ========================================================================= //
// ------------------------- Tabular Counters Output ----------------------- //
// ========================================================================= //
void
BM_Counters_Tabular
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
}
state
.
counters
.
insert
({
{
"Foo"
,
1
},
{
"Bar"
,
2
},
{
"Baz"
,
4
},
{
"Bat"
,
8
},
{
"Frob"
,
16
},
{
"Lob"
,
32
},
});
}
BENCHMARK
(
BM_Counters_Tabular
);
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_Counters_Tabular %console_report "
"[ ]*%hrfloat [ ]*%hrfloat [ ]*%hrfloat "
"[ ]*%hrfloat [ ]*%hrfloat [ ]*%hrfloat$"
}});
ADD_CASES
(
TC_JSONOut
,
{{
"
\"
name
\"
:
\"
BM_Counters_Tabular
\"
,$"
},
{
"
\"
iterations
\"
: %int,$"
,
MR_Next
},
{
"
\"
real_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
cpu_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
time_unit
\"
:
\"
ns
\"
,$"
,
MR_Next
},
{
"
\"
Bar
\"
: %float,$"
,
MR_Next
},
{
"
\"
Bat
\"
: %float,$"
,
MR_Next
},
{
"
\"
Baz
\"
: %float,$"
,
MR_Next
},
{
"
\"
Foo
\"
: %float,$"
,
MR_Next
},
{
"
\"
Frob
\"
: %float,$"
,
MR_Next
},
{
"
\"
Lob
\"
: %float$"
,
MR_Next
},
{
"}"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Tabular
\"
,%csv_report,"
"%float,%float,%float,%float,%float,%float$"
}});
// VS2013 does not allow this function to be passed as a lambda argument
// to CHECK_BENCHMARK_RESULTS()
void
CheckTabular
(
Results
const
&
e
)
{
CHECK_COUNTER_VALUE
(
e
,
int
,
"Foo"
,
EQ
,
1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"Bar"
,
EQ
,
2
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"Baz"
,
EQ
,
4
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"Bat"
,
EQ
,
8
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"Frob"
,
EQ
,
16
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"Lob"
,
EQ
,
32
);
}
CHECK_BENCHMARK_RESULTS
(
"BM_Counters_Tabular"
,
&
CheckTabular
);
// ========================================================================= //
// --------------------------- TEST CASES END ------------------------------ //
// ========================================================================= //
int
main
(
int
argc
,
char
*
argv
[])
{
RunOutputTests
(
argc
,
argv
);
}
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