Ignition Common

API Reference

4.5.0

Used to perform application-wide performance profiling. More...

#include <Profiler.hh>

Public Member Functions

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 hash parameter to be cached between executions of BeginSample, so that hashes don't need to be recomputed. More...
 
void EndSample ()
 End a profiling sample. More...
 
std::string ImplementationName () const
 Get the underlying profiler implentation name. More...
 
void LogText (const char *_text)
 Log text to profiler output (if supported) If the underlying profiler implementation supports additional log messages, this can be used to send. More...
 
void SetThreadName (const char *_name)
 Set the name of the current thread. More...
 
bool Valid () const
 Detect if profiler is enabled and has an implementation. More...
 

Protected Member Functions

 Profiler ()
 Constructor. More...
 
 ~Profiler ()
 Destructor. More...
 
- Protected Member Functions inherited from SingletonT< Profiler >
 SingletonT ()
 Constructor. More...
 
virtual ~SingletonT ()
 Destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SingletonT< Profiler >
static ProfilerInstance ()
 Get an instance of the singleton. More...
 

Detailed Description

Used to perform application-wide performance profiling.

This class provides the necessary infrastructure for recording profiling information of an application while it is running. The actual profiler implementation can be choosen at runtime, and is invoked through a series of macros found below.

In general, users shouldn't directly interface with this class, but instead use the profiling macros, which can be enabled/disabled at compile time, which eliminates any performance impact of profiling.

Profiler is enabled by setting IGN_ENABLE_PROFILER at compile time.

The profiler header also exports several convenience macros to make adding inspection points easier.

  • IGN_PROFILE_THREAD_NAME - Set the name of the current profiled thread.
  • IGN_PROFILE_LOG_TEXT - Log text to the profiler console (if supported)
  • IGN_PROFILE_BEGIN - Begin a named profile sample
  • IGN_PROFILE_END - End a named profile sample
  • IGN_PROFILE - RAII-style profile sample. The sample will end at the end of the current scope.

Constructor & Destructor Documentation

◆ Profiler()

Profiler ( )
protected

Constructor.

◆ ~Profiler()

~Profiler ( )
protected

Destructor.

Member Function Documentation

◆ BeginSample()

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 hash parameter to be cached between executions of BeginSample, so that hashes don't need to be recomputed.

Parameters
[in]_nameName of the sample
[in,out]_hashAn optional hash value that can be cached between executions.

Referenced by ScopedProfile::ScopedProfile().

◆ EndSample()

void EndSample ( )

End a profiling sample.

Referenced by ScopedProfile::~ScopedProfile().

◆ ImplementationName()

std::string ImplementationName ( ) const

Get the underlying profiler implentation name.

◆ LogText()

void LogText ( const char *  _text)

Log text to profiler output (if supported) If the underlying profiler implementation supports additional log messages, this can be used to send.

Currently, the Remotery implentation supports this functionality.

Parameters
[in]_textText to log.

◆ SetThreadName()

void SetThreadName ( const char *  _name)

Set the name of the current thread.

Parameters
[in]_nameName to set

◆ Valid()

bool Valid ( ) const

Detect if profiler is enabled and has an implementation.


The documentation for this class was generated from the following file: