18 #ifndef GZ_COMMON_PROFILER_HH_
19 #define GZ_COMMON_PROFILER_HH_
24 #include <gz/common/config.hh>
25 #include <gz/common/profiler/Export.hh>
84 public:
void BeginSample(
const char *_name, uint32_t *_hash =
nullptr);
96 private: ProfilerImpl *impl;
125 #ifndef GZ_PROFILER_ENABLE
127 #define GZ_PROFILER_ENABLE 0
130 #if GZ_PROFILER_ENABLE
132 #define GZ_PROFILE_THREAD_NAME(name) \
133 gz::common::Profiler::Instance()->SetThreadName(name);
135 #define GZ_PROFILE_LOG_TEXT(name) \
136 gz::common::Profiler::Instance()->LogText(name);
138 #define GZ_PROFILE_BEGIN(name) \
139 gz::common::Profiler::Instance()->BeginSample(name)
141 #define GZ_PROFILE_END() \
142 gz::common::Profiler::Instance()->EndSample()
145 #define GZ_PROFILE_L(name, line) \
146 static uint32_t __hash##line = 0; \
147 gz::common::ScopedProfile __profile##line(name, &__hash##line);
149 #define GZ_PROFILE(name) GZ_PROFILE_L(name, __LINE__);
153 #define GZ_PROFILE_THREAD_NAME(name) ((void) name)
154 #define GZ_PROFILE_LOG_TEXT(name) ((void) name)
155 #define GZ_PROFILE_BEGIN(name) ((void) name)
156 #define GZ_PROFILE_END() ((void) 0)
157 #define GZ_PROFILE_L(name, line) ((void) name)
158 #define GZ_PROFILE(name) ((void) name)
162 #define GZ_PROFILER_VALID \
163 GZ_PROFILER_ENABLE && gz::common::Profiler::Instance()->Valid()