Commit 62288754 authored by Pádraig Ó Conbhuí's avatar Pádraig Ó Conbhuí
Browse files

Add benchmark with null-clock for pure PERForate timing

parent a7330f10
......@@ -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.
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment