9#ifndef PROTEUS_TIME_TRACING_H
10#define PROTEUS_TIME_TRACING_H
19struct TimeTraceScopeWrapper;
30 std::unique_ptr<TimeTraceScopeWrapper> Pimpl;
34 using Clock = std::chrono::steady_clock;
37 explicit Timer(
bool Enabled =
true);
41 template <
class Duration> uint64_t
elapsedAs()
const {
43 !std::chrono::treat_as_floating_point_v<typename Duration::rep>,
44 "Timer::elapsedAs only supports integral duration reps");
47 return std::chrono::duration_cast<Duration>(Clock::now() - Start).count();
54 Clock::time_point Start;
59#define PROTEUS_TIMESCOPE_VAR(Line) STT_##Line
60#define PROTEUS_TIMESCOPE_VAR_EXPAND(Line) PROTEUS_TIMESCOPE_VAR(Line)
61#define PROTEUS_TIMESCOPE_1(Label) \
62 ::proteus::ScopedTimeTrace PROTEUS_TIMESCOPE_VAR_EXPAND(__LINE__)(Label);
63#define PROTEUS_TIMESCOPE_2(Class, Method) \
64 PROTEUS_TIMESCOPE_1(#Class "::" #Method)
65#define PROTEUS_GET_TIMESCOPE(_1, _2, NAME, ...) NAME
66#define TIMESCOPE(...) \
67 PROTEUS_GET_TIMESCOPE(__VA_ARGS__, PROTEUS_TIMESCOPE_2, \
68 PROTEUS_TIMESCOPE_1)(__VA_ARGS__)
Definition TimeTracing.h:21
ScopedTimeTrace(ScopedTimeTrace &&)=default
ScopedTimeTrace & operator=(ScopedTimeTrace &&)=default
Definition TimeTracing.h:33
uint64_t elapsedAs() const
Definition TimeTracing.h:41
void reset()
Definition TimeTracing.cpp:68
uint64_t elapsed()
Definition TimeTracing.cpp:66
Definition MemoryCache.h:27