18 #ifndef IGNITION_COMMON_PROFILER_HH_
19 #define IGNITION_COMMON_PROFILER_HH_
24 #include <ignition/common/profiler/Export.hh>
26 #include <ignition/common/config.hh>
56 class IGNITION_COMMON_PROFILER_VISIBLE
Profiler
84 public:
void BeginSample(
const char *_name, uint32_t *_hash =
nullptr);
96 private: ProfilerImpl *impl;
125 #ifndef IGN_PROFILER_ENABLE
127 #define IGN_PROFILER_ENABLE 0
130 #if IGN_PROFILER_ENABLE
132 #define IGN_PROFILE_THREAD_NAME(name) \
133 ignition::common::Profiler::Instance()->SetThreadName(name);
135 #define IGN_PROFILE_LOG_TEXT(name) \
136 ignition::common::Profiler::Instance()->LogText(name);
138 #define IGN_PROFILE_BEGIN(name) \
139 ignition::common::Profiler::Instance()->BeginSample(name)
141 #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);
149 #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)
162 #define IGN_PROFILER_VALID \
163 IGN_PROFILER_ENABLE && ignition::common::Profiler::Instance()->Valid()
Used to perform application-wide performance profiling.
Definition: Profiler.hh:58
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...
void LogText(const char *_text)
Log text to profiler output (if supported) If the underlying profiler implementation supports additio...
bool Valid() const
Detect if profiler is enabled and has an implementation.
void SetThreadName(const char *_name)
Set the name of the current thread.
std::string ImplementationName() const
Get the underlying profiler implentation name.
void EndSample()
End a profiling sample.
Used to provide C++ RAII-style profiling sample. The sample will start on the construction of the Sco...
Definition: Profiler.hh:106
~ScopedProfile()
Destructor. Stops profile sample.
Definition: Profiler.hh:117
ScopedProfile(const char *_name, uint32_t *_hash)
Constructor. Starts profile sample.
Definition: Profiler.hh:111
Singleton template class.
Definition: SingletonT.hh:28
static Profiler * Instance()
Get an instance of the singleton.
Definition: SingletonT.hh:30
Forward declarations for the common classes.