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
3c2d7f53
Commit
3c2d7f53
authored
Apr 27, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User counter tests: first version.
parent
b273d9b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
CMakeLists.txt
test/CMakeLists.txt
+3
-0
output_test_helper.cc
test/output_test_helper.cc
+3
-0
user_counters_test.cc
test/user_counters_test.cc
+75
-0
No files found.
test/CMakeLists.txt
View file @
3c2d7f53
...
@@ -92,6 +92,9 @@ add_test(multiple_ranges_test multiple_ranges_test --benchmark_min_time=0.01)
...
@@ -92,6 +92,9 @@ add_test(multiple_ranges_test multiple_ranges_test --benchmark_min_time=0.01)
compile_output_test
(
reporter_output_test
)
compile_output_test
(
reporter_output_test
)
add_test
(
reporter_output_test reporter_output_test --benchmark_min_time=0.01
)
add_test
(
reporter_output_test reporter_output_test --benchmark_min_time=0.01
)
compile_output_test
(
user_counters_test
)
add_test
(
user_counters_test user_counters_test --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/output_test_helper.cc
View file @
3c2d7f53
...
@@ -48,6 +48,9 @@ SubMap& GetSubstitutions() {
...
@@ -48,6 +48,9 @@ SubMap& GetSubstitutions() {
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,"
+
safe_dec_re
+
",,,,"
},
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,"
+
safe_dec_re
+
",,,,"
},
{
"%csv_items_report"
,
{
"%csv_items_report"
,
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,,"
+
safe_dec_re
+
",,,"
},
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,,"
+
safe_dec_re
+
",,,"
},
{
"%csv_bytes_items_report"
,
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",,,"
},
{
"%csv_label_report_begin"
,
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,,,"
},
{
"%csv_label_report_begin"
,
"[0-9]+,"
+
safe_dec_re
+
","
+
safe_dec_re
+
",ns,,,"
},
{
"%csv_label_report_end"
,
",,"
}};
{
"%csv_label_report_end"
,
",,"
}};
return
map
;
return
map
;
...
...
test/user_counters_test.cc
0 → 100644
View file @
3c2d7f53
#undef NDEBUG
#include <utility>
#include "benchmark/benchmark.h"
#include "output_test.h"
// ========================================================================= //
// ---------------------- Testing Prologue Output -------------------------- //
// ========================================================================= //
ADD_CASES
(
TC_ConsoleOut
,
{{
"^[-]+$"
,
MR_Next
},
{
"^Benchmark %s Time %s CPU %s Iterations UserCounters...$"
,
MR_Next
},
{
"^[-]+$"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"%csv_header,
\"
bar
\"
,
\"
foo
\"
"
}});
// ========================================================================= //
// ------------------------- Basic Counters Output ------------------------- //
// ========================================================================= //
void
BM_Counters_Simple
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
}
state
.
counters
[
"foo"
]
=
1
;
state
.
counters
[
"bar"
]
=
2
;
//state.SetItemsProcessed(150);
//state.SetBytesProcessed(364);
}
BENCHMARK
(
BM_Counters_Simple
);
//->ThreadRange(1, 32);
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_Counters_Simple %console_report bar=%float foo=%float$"
}});
ADD_CASES
(
TC_JSONOut
,
{{
"
\"
name
\"
:
\"
BM_Counters_Simple
\"
,$"
},
{
"
\"
iterations
\"
: %int,$"
,
MR_Next
},
{
"
\"
real_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
cpu_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
time_unit
\"
:
\"
ns
\"
,$"
,
MR_Next
},
{
"
\"
bar
\"
: %float,$"
,
MR_Next
},
{
"
\"
foo
\"
: %float$"
,
MR_Next
},
{
"}"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Simple
\"
,%csv_report,%float,%float$"
}});
// ========================================================================= //
// ------------------------- Basic Counters Output ------------------------- //
// ========================================================================= //
void
BM_Counters_WithBytesAndItemsPSec
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
}
state
.
counters
[
"foo"
]
=
1
;
state
.
counters
[
"bar"
]
=
2
;
state
.
SetItemsProcessed
(
150
);
state
.
SetBytesProcessed
(
364
);
}
BENCHMARK
(
BM_Counters_WithBytesAndItemsPSec
);
//->ThreadRange(1, 32);
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_Counters_WithBytesAndItemsPSec %console_report "
"bar=%float foo=%float +%floatB/s +%float items/s$"
}});
ADD_CASES
(
TC_JSONOut
,
{{
"
\"
name
\"
:
\"
BM_Counters_WithBytesAndItemsPSec
\"
,$"
},
{
"
\"
iterations
\"
: %int,$"
,
MR_Next
},
{
"
\"
real_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
cpu_time
\"
: %int,$"
,
MR_Next
},
{
"
\"
time_unit
\"
:
\"
ns
\"
,$"
,
MR_Next
},
{
"
\"
bytes_per_second
\"
: %int,$"
,
MR_Next
},
{
"
\"
items_per_second
\"
: %int,$"
,
MR_Next
},
{
"
\"
bar
\"
: %float,$"
,
MR_Next
},
{
"
\"
foo
\"
: %float$"
,
MR_Next
},
{
"}"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_WithBytesAndItemsPSec
\"
,"
"%csv_bytes_items_report,%float,%float$"
}});
// ========================================================================= //
// --------------------------- 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