Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
performance
PERForate
Commits
62288754
Commit
62288754
authored
Oct 15, 2020
by
Pádraig Ó Conbhuí
Browse files
Add benchmark with null-clock for pure PERForate timing
parent
a7330f10
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/perforate/scoped_trace.bench.cpp
View file @
62288754
...
...
@@ -29,6 +29,15 @@ static std::vector<size_t> to_measure() {
return
value
;
}
struct
null_clock
{
using
rep
=
size_t
;
using
period
=
std
::
ratio
<
1
,
1
>
;
using
duration
=
std
::
chrono
::
duration
<
rep
,
period
>
;
using
time_point
=
std
::
chrono
::
time_point
<
null_clock
>
;
static
time_point
now
()
{
return
time_point
(
std
::
chrono
::
seconds
{
0
});
}
};
TEST_CASE
(
"perforate::scoped_trace"
,
"[scoped_trace][benchmark]"
)
{
BENCHMARK
(
"std::chrono::high_resolution_clock::now()"
)
{
return
std
::
chrono
::
high_resolution_clock
::
now
();
...
...
@@ -36,6 +45,13 @@ TEST_CASE("perforate::scoped_trace", "[scoped_trace][benchmark]") {
BENCHMARK
(
"scoped_trace overhead"
)
{
PERFORATE_SCOPED_TRACE
(
nullptr
);
};
BENCHMARK
(
"scoped_trace null clock overhead"
)
{
auto
s
=
perforate
::
scoped_trace
<
class
tsc_tag
,
0
,
null_clock
>
(
nullptr
);
return
s
;
};
BENCHMARK
(
"null_clock::now()"
)
{
return
null_clock
::
now
();
};
// Measure the "PERFORATE_SCOPED_TRACE overhead to a loop with PERForate"
// Assume it's around 100ns.
{
...
...
@@ -57,7 +73,7 @@ TEST_CASE("perforate::scoped_trace", "[scoped_trace][benchmark]") {
// Outside loop
{
PERFORATE_SCOPED_TRACE
(
"measuring work outside loop"
)
.
call_count
(
number_of_iterations
);
.
call_count
(
number_of_iterations
);
for
(
size_t
i
=
0
;
i
<
number_of_iterations
;
i
++
)
{
use
(
to_measure
());
...
...
Write
Preview
Supports
Markdown
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