24 class ProfilerCollector;
38 void Reset(ProfilerCollector& collector);
60 void ExitScope (ProfilerCollector& collector)
noexcept;
64 void EnterScope(ProfilerCollector& collector, uint64_t nameHash,
const char* name,
65 bool isWait =
false,
const char* file =
"",
int line = 0) noexcept;
82 ProfilerCollector& m_collector;
112#ifndef TACHYON_PROFILE_ENABLED
113# define TACHYON_PROFILE_ENABLED 1
116#if TACHYON_PROFILE_ENABLED
117# define TACHYON_PROFILE_CONCAT2(a, b) a##b
118# define TACHYON_PROFILE_CONCAT(a, b) TACHYON_PROFILE_CONCAT2(a, b)
121# define TACHYON_PROFILE_SCOPE(name) \
122 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__) \
123 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, false }; \
124 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
125 ::tachyon::Diagnostics::MainThreadCollector(), TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__))
127# define TACHYON_PROFILE_SCOPE_WAIT(name) \
128 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__) \
129 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, true }; \
130 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
131 ::tachyon::Diagnostics::MainThreadCollector(), TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__))
134# define TACHYON_PROFILE_SCOPE_REF(locationLValue) \
135 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
136 ::tachyon::Diagnostics::MainThreadCollector(), (locationLValue))
139# define TACHYON_PROFILE_FRAME_BEGIN(name) \
141 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_frameLoc_, __LINE__) \
142 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, false }; \
143 ::tachyon::Diagnostics::BeginFrame(::tachyon::Diagnostics::MainThreadCollector()); \
144 ::tachyon::Diagnostics::EnterScope(::tachyon::Diagnostics::MainThreadCollector(), \
145 TACHYON_PROFILE_CONCAT(s_frameLoc_, __LINE__)); \
147# define TACHYON_PROFILE_FRAME_END() \
149 ::tachyon::Diagnostics::ExitScope(::tachyon::Diagnostics::MainThreadCollector()); \
150 ::tachyon::Diagnostics::EndFrame(::tachyon::Diagnostics::MainThreadCollector()); \
153# define TACHYON_PROFILE_SCOPE(name) ((void)0)
154# define TACHYON_PROFILE_SCOPE_WAIT(name) ((void)0)
155# define TACHYON_PROFILE_SCOPE_REF(locationLValue) ((void)0)
156# define TACHYON_PROFILE_FRAME_BEGIN(name) ((void)0)
157# define TACHYON_PROFILE_FRAME_END() ((void)0)
ScopedTimer(const ScopedTimer &)=delete
~ScopedTimer() noexcept
Definition gui_profiler.h:76
ScopedTimer & operator=(const ScopedTimer &)=delete
ScopedTimer(ProfilerCollector &collector, ScopeLocation &loc) noexcept
Definition gui_profiler.h:71
void Reset(ProfilerCollector &collector)
Discards all nodes and history; cached scope sites re-resolve.
void BeginFrame(ProfilerCollector &collector)
Frame boundaries: call once each, around all scopes for the frame.
double LastFrameTotalMs(const ProfilerCollector &collector)
Smoothed total of the root scope(s): the frame total, in milliseconds.
ProfilerCollector & MainThreadCollector()
void EnterScope(ProfilerCollector &collector, ScopeLocation &loc) noexcept
Cached scope entry / exit, as the macros use.
void ExitScope(ProfilerCollector &collector) noexcept
Cached scope entry / exit, as the macros use.
void SetProfilingEnabled(bool enabled)
std::span< const ProfileSample > LastFrameSamples(const ProfilerCollector &collector)
The nodes of the last finalized frame, depth-first. Valid until the next EndFrame.
bool IsProfilingEnabled()
void EndFrame(ProfilerCollector &collector)
Frame boundaries: call once each, around all scopes for the frame.
Definition gui_logging.h:24
One finalized node, depth-first. Durations are windowed averages (~4 updates/s).
Definition gui_profiler.h:88
const char * name
Definition gui_profiler.h:91
double minMs
Definition gui_profiler.h:98
int32_t depth
Definition gui_profiler.h:94
uint64_t parentKey
Definition gui_profiler.h:90
bool isWait
Definition gui_profiler.h:100
double selfMs
Definition gui_profiler.h:97
double totalMs
Definition gui_profiler.h:96
const char * file
Definition gui_profiler.h:92
int32_t callCount
Definition gui_profiler.h:95
int32_t line
Definition gui_profiler.h:93
double maxMs
Definition gui_profiler.h:99
uint64_t key
Definition gui_profiler.h:89
Per-call-site descriptor, static at each TACHYON_PROFILE_SCOPE site.
Definition gui_profiler.h:44
uint32_t cachedGeneration
Definition gui_profiler.h:53
uint64_t cachedKey
Definition gui_profiler.h:51
int line
Definition gui_profiler.h:48
const char * name
Definition gui_profiler.h:46
int32_t cachedIndex
Definition gui_profiler.h:52
uint64_t nameHash
Definition gui_profiler.h:45
const char * file
Definition gui_profiler.h:47
bool isWait
Definition gui_profiler.h:49