24 class ProfilerCollector;
38 void Reset(ProfilerCollector& collector);
63 void ExitScope (ProfilerCollector& collector)
noexcept;
67 void EnterScope(ProfilerCollector& collector, uint64_t nameHash,
const char* name,
68 bool isWait =
false,
const char* file =
"",
int line = 0) noexcept;
85 ProfilerCollector& m_collector;
118#ifndef TACHYON_PROFILE_ENABLED
119# define TACHYON_PROFILE_ENABLED 1
122#if TACHYON_PROFILE_ENABLED
123# define TACHYON_PROFILE_CONCAT2(a, b) a##b
124# define TACHYON_PROFILE_CONCAT(a, b) TACHYON_PROFILE_CONCAT2(a, b)
127# define TACHYON_PROFILE_SCOPE(name) \
128 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__) \
129 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, false }; \
130 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
131 ::tachyon::Diagnostics::MainThreadCollector(), TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__))
133# define TACHYON_PROFILE_SCOPE_WAIT(name) \
134 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__) \
135 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, true }; \
136 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
137 ::tachyon::Diagnostics::MainThreadCollector(), TACHYON_PROFILE_CONCAT(s_profLoc_, __LINE__))
140# define TACHYON_PROFILE_SCOPE_REF(locationLValue) \
141 ::tachyon::Diagnostics::ScopedTimer TACHYON_PROFILE_CONCAT(profTimer_, __LINE__)( \
142 ::tachyon::Diagnostics::MainThreadCollector(), (locationLValue))
145# define TACHYON_PROFILE_FRAME_BEGIN(name) \
147 static ::tachyon::Diagnostics::ScopeLocation TACHYON_PROFILE_CONCAT(s_frameLoc_, __LINE__) \
148 { ::tachyon::Hash::CalculateConst(name), name, __FILE__, __LINE__, false }; \
149 ::tachyon::Diagnostics::BeginFrame(::tachyon::Diagnostics::MainThreadCollector()); \
150 ::tachyon::Diagnostics::EnterScope(::tachyon::Diagnostics::MainThreadCollector(), \
151 TACHYON_PROFILE_CONCAT(s_frameLoc_, __LINE__)); \
153# define TACHYON_PROFILE_FRAME_END() \
155 ::tachyon::Diagnostics::ExitScope(::tachyon::Diagnostics::MainThreadCollector()); \
156 ::tachyon::Diagnostics::EndFrame(::tachyon::Diagnostics::MainThreadCollector()); \
159# define TACHYON_PROFILE_SCOPE(name) ((void)0)
160# define TACHYON_PROFILE_SCOPE_WAIT(name) ((void)0)
161# define TACHYON_PROFILE_SCOPE_REF(locationLValue) ((void)0)
162# define TACHYON_PROFILE_FRAME_BEGIN(name) ((void)0)
163# define TACHYON_PROFILE_FRAME_END() ((void)0)
ScopedTimer(const ScopedTimer &)=delete
~ScopedTimer() noexcept
Definition gui_profiler.h:79
ScopedTimer & operator=(const ScopedTimer &)=delete
ScopedTimer(ProfilerCollector &collector, ScopeLocation &loc) noexcept
Definition gui_profiler.h:74
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 SetSmoothingWindow(ProfilerCollector &collector, int64_t nanoseconds)
How long the smoothed durations average over: 250 ms by default, as the FPS readout.
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:91
const char * name
Definition gui_profiler.h:94
double minMs
Definition gui_profiler.h:101
int32_t depth
Definition gui_profiler.h:97
uint64_t parentKey
Definition gui_profiler.h:93
bool isWait
Definition gui_profiler.h:106
double selfMs
Definition gui_profiler.h:100
double totalMs
Definition gui_profiler.h:99
double frameTotalMs
This frame alone, not smoothed: for measuring a fixed run of frames.
Definition gui_profiler.h:104
const char * file
Definition gui_profiler.h:95
int32_t callCount
Definition gui_profiler.h:98
double frameSelfMs
Definition gui_profiler.h:105
int32_t line
Definition gui_profiler.h:96
double maxMs
Definition gui_profiler.h:102
uint64_t key
Definition gui_profiler.h:92
Per-call-site descriptor, static at each TACHYON_PROFILE_SCOPE site.
Definition gui_profiler.h:47
uint32_t cachedGeneration
Definition gui_profiler.h:56
uint64_t cachedKey
Definition gui_profiler.h:54
int line
Definition gui_profiler.h:51
const char * name
Definition gui_profiler.h:49
int32_t cachedIndex
Definition gui_profiler.h:55
uint64_t nameHash
Definition gui_profiler.h:48
const char * file
Definition gui_profiler.h:50
bool isWait
Definition gui_profiler.h:52