Go to the documentation of this file.
18 #ifndef GZ_COMMON_PROFILER_HH_
19 #define GZ_COMMON_PROFILER_HH_
25 #include <gz/common/config.hh>
26 #include <gz/common/profiler/Export.hh>
57 class IGNITION_COMMON_PROFILER_VISIBLE
Profiler
68 public:
void SetThreadName(
const char *_name);
76 public:
void LogText(
const char *_text);
85 public:
void BeginSample(
const char *_name, uint32_t *_hash =
nullptr);
88 public:
void EndSample();
94 public:
bool Valid()
const;
97 private: ProfilerImpl *impl;
126 #ifndef IGN_PROFILER_ENABLE
127 #define IGN_PROFILER_ENABLE 0
131 #if IGN_PROFILER_ENABLE
132 #define IGN_PROFILE_THREAD_NAME(name) \
134 ignition::common::Profiler::Instance()->SetThreadName(name);
135 #define IGN_PROFILE_LOG_TEXT(name) \
137 ignition::common::Profiler::Instance()->LogText(name);
138 #define IGN_PROFILE_BEGIN(name) \
140 ignition::common::Profiler::Instance()->BeginSample(name)
141 #define IGN_PROFILE_END() \
143 ignition::common::Profiler::Instance()->EndSample()
146 #define IGN_PROFILE_L(name, line) \
147 static uint32_t __hash##line = 0; \
148 ignition::common::ScopedProfile __profile##line(name, &__hash##line);
149 #define IGN_PROFILE(name) IGN_PROFILE_L(name, __LINE__);
154 #define IGN_PROFILE_THREAD_NAME(name) ((void) name)
155 #define IGN_PROFILE_LOG_TEXT(name) ((void) name)
156 #define IGN_PROFILE_BEGIN(name) ((void) name)
157 #define IGN_PROFILE_END() ((void) 0)
158 #define IGN_PROFILE_L(name, line) ((void) name)
159 #define IGN_PROFILE(name) ((void) name)
160 #endif // IGN_PROFILER_ENABLE
163 #define IGN_PROFILER_VALID \
164 IGN_PROFILER_ENABLE && ignition::common::Profiler::Instance()->Valid()
166 #endif // GZ_COMMON_PROFILER_HH_
Forward declarations for the common classes.
void BeginSample(const char *_name, uint32_t *_hash=nullptr)
Begin a named profiling sample. Begins a CPU profiler sample with a given name. Can optionally take a...
ScopedProfile(const char *_name, uint32_t *_hash)
Constructor. Starts profile sample.
Definition: gz/common/Profiler.hh:112
static Profiler * Instance()
Get an instance of the singleton.
Definition: gz/common/SingletonT.hh:32
void EndSample()
End a profiling sample.
~ScopedProfile()
Destructor. Stops profile sample.
Definition: gz/common/Profiler.hh:118
Singleton template class.
Definition: gz/common/SingletonT.hh:29
Used to provide C++ RAII-style profiling sample. The sample will start on the construction of the Sco...
Definition: gz/common/Profiler.hh:106
Used to perform application-wide performance profiling.
Definition: gz/common/Profiler.hh:57