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
da69e5de
Commit
da69e5de
authored
Apr 28, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User counters: add more tests.
parent
8c757a3b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
user_counters_test.cc
test/user_counters_test.cc
+15
-4
No files found.
test/user_counters_test.cc
View file @
da69e5de
...
@@ -22,7 +22,7 @@ void BM_Counters_Simple(benchmark::State& state) {
...
@@ -22,7 +22,7 @@ void BM_Counters_Simple(benchmark::State& state) {
while
(
state
.
KeepRunning
())
{
while
(
state
.
KeepRunning
())
{
}
}
state
.
counters
[
"foo"
]
=
1
;
state
.
counters
[
"foo"
]
=
1
;
state
.
counters
[
"bar"
]
=
2
;
state
.
counters
[
"bar"
]
=
2
*
state
.
iterations
()
;
}
}
BENCHMARK
(
BM_Counters_Simple
);
//->ThreadRange(1, 32);
BENCHMARK
(
BM_Counters_Simple
);
//->ThreadRange(1, 32);
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_Counters_Simple %console_report bar=%hrfloat foo=%hrfloat$"
}});
ADD_CASES
(
TC_ConsoleOut
,
{{
"^BM_Counters_Simple %console_report bar=%hrfloat foo=%hrfloat$"
}});
...
@@ -36,8 +36,10 @@ ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Simple\",$"},
...
@@ -36,8 +36,10 @@ ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Simple\",$"},
{
"}"
,
MR_Next
}});
{
"}"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Simple
\"
,%csv_report,%float,%float$"
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Simple
\"
,%csv_report,%float,%float$"
}});
CHECK_BENCHMARK_RESULTS
(
"BM_Counters_Simple"
,
[](
ResultsCheckerEntry
const
&
e
)
{
CHECK_BENCHMARK_RESULTS
(
"BM_Counters_Simple"
,
[](
ResultsCheckerEntry
const
&
e
)
{
double
its
=
e
.
GetAs
<
double
>
(
"iterations"
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"foo"
,
EQ
,
1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"foo"
,
EQ
,
1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"bar"
,
EQ
,
2
);
// check that the value of bar is within 0.1% of the expected value
CHECK_COUNTER_VALUE
(
e
,
double
,
"bar"
,
EQ_EPS
,
2.
*
its
,
0.001
*
its
);
});
});
// ========================================================================= //
// ========================================================================= //
...
@@ -73,8 +75,10 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_WithBytesAndItemsPSec",
...
@@ -73,8 +75,10 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_WithBytesAndItemsPSec",
[](
ResultsCheckerEntry
const
&
e
)
{
[](
ResultsCheckerEntry
const
&
e
)
{
CHECK_COUNTER_VALUE
(
e
,
int
,
"foo"
,
EQ
,
1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"foo"
,
EQ
,
1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"bar"
,
EQ
,
num_calls1
);
CHECK_COUNTER_VALUE
(
e
,
int
,
"bar"
,
EQ
,
num_calls1
);
//TODO CHECK_RESULT_VALUE(e, int, "bytes_per_second", EQ, 364 / e.duration_cpu_time());
// check that the values are within 0.1% of the expected values
//TODO CHECK_RESULT_VALUE(e, int, "items_per_second", EQ, 150 / e.duration_cpu_time());
double
t
=
e
.
DurationCPUTime
();
// this (and not real time) is the time used
CHECK_RESULT_VALUE
(
e
,
double
,
"bytes_per_second"
,
EQ_EPS
,
364.
/
t
,
0.001
*
t
);
CHECK_RESULT_VALUE
(
e
,
double
,
"items_per_second"
,
EQ_EPS
,
150.
/
t
,
0.001
*
t
);
});
});
// ========================================================================= //
// ========================================================================= //
...
@@ -99,6 +103,13 @@ ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Rate\",$"},
...
@@ -99,6 +103,13 @@ ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Rate\",$"},
{
"
\"
foo
\"
: %float$"
,
MR_Next
},
{
"
\"
foo
\"
: %float$"
,
MR_Next
},
{
"}"
,
MR_Next
}});
{
"}"
,
MR_Next
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Rate
\"
,%csv_report,%float,%float$"
}});
ADD_CASES
(
TC_CSVOut
,
{{
"^
\"
BM_Counters_Rate
\"
,%csv_report,%float,%float$"
}});
CHECK_BENCHMARK_RESULTS
(
"BM_Counters_Rate"
,
[](
ResultsCheckerEntry
const
&
e
)
{
// check that the values are within 0.1% of the expected values
double
t
=
e
.
DurationCPUTime
();
// this (and not real time) is the time used
CHECK_COUNTER_VALUE
(
e
,
double
,
"foo"
,
EQ_EPS
,
5.
/
t
,
0.001
*
t
);
CHECK_COUNTER_VALUE
(
e
,
double
,
"bar"
,
EQ_EPS
,
2.
/
t
,
0.001
*
t
);
});
// ========================================================================= //
// ========================================================================= //
// ------------------------- Thread Counters Output ------------------------ //
// ------------------------- Thread Counters Output ------------------------ //
...
...
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