Go to the documentation of this file.
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>
56 class IGNITION_COMMON_PROFILER_VISIBLE
Profiler
67 public:
void SetThreadName(
const char *_name);
75 public:
void LogText(
const char *_text);
84 public:
void BeginSample(
const char *_name, uint32_t *_hash =
nullptr);
87 public:
void EndSample();
93 public:
bool Valid()
const;
96 private: ProfilerImpl *impl;
125 #ifndef IGN_PROFILER_ENABLE
126 #define IGN_PROFILER_ENABLE 0
130 #if IGN_PROFILER_ENABLE
131 #define IGN_PROFILE_THREAD_NAME(name) \
133 ignition::common::Profiler::Instance()->SetThreadName(name);
134 #define IGN_PROFILE_LOG_TEXT(name) \
136 ignition::common::Profiler::Instance()->LogText(name);
137 #define IGN_PROFILE_BEGIN(name) \
139 ignition::common::Profiler::Instance()->BeginSample(name)
140 #define IGN_PROFILE_END() \
142 ignition::common::Profiler::Instance()->EndSample()
145 #define IGN_PROFILE_L(name, line) \
146 static uint32_t __hash##line = 0; \
147 ignition::common::ScopedProfile __profile##line(name, &__hash##line);
148 #define IGN_PROFILE(name) IGN_PROFILE_L(name, __LINE__);
153 #define IGN_PROFILE_THREAD_NAME(name) ((void) name)
154 #define IGN_PROFILE_LOG_TEXT(name) ((void) name)
155 #define IGN_PROFILE_BEGIN(name) ((void) name)
156 #define IGN_PROFILE_END() ((void) 0)
157 #define IGN_PROFILE_L(name, line) ((void) name)
158 #define IGN_PROFILE(name) ((void) name)
159 #endif // IGN_PROFILER_ENABLE
162 #define IGN_PROFILER_VALID \
163 IGN_PROFILER_ENABLE && ignition::common::Profiler::Instance()->Valid()
165 #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:111
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:117
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:105
Used to perform application-wide performance profiling.
Definition: gz/common/Profiler.hh:56