OGRE-Next: Ogre::Profiler Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Ogre::Profiler Class Reference
Core » General

The profiler allows you to measure the performance of your code. More...

`#include <OgreProfiler.h>`

Inheritance diagram for Ogre::Profiler:
[legend]

## Public Member Functions
| Profiler ()
| ~Profiler ()
void | addListener (ProfileSessionListener *listener)
void | beginGPUEvent (const String &event)
| Mark the beginning of a GPU event group.
void | beginGPUSample (const String &name, uint32 *hashCache)
void | beginProfile (const String &profileName, uint32 groupID=(uint32) OGREPROF_USER_DEFAULT, ProfileSampleFlags::ProfileSampleFlags flags=ProfileSampleFlags::FlagsNone)
| Begins a profile.
void | disableProfile (const String &profileName)
| Disables a profile.
void | enableProfile (const String &profileName)
| Enables a previously disabled profile.
void | endGPUEvent (const String &event)
| Mark the end of a GPU event group.
void | endGPUSample (const String &name)
void | endProfile (const String &profileName, uint32 groupID=(uint32) OGREPROF_USER_DEFAULT)
| Ends a profile.
bool | getEnabled () const
| Gets whether this profiler is enabled.
OfflineProfiler & | getOfflineProfiler ()
uint32 | getProfileGroupMask () const
| Get the mask which all profiles must pass to be enabled.
Timer * | getTimer ()
| Retrieves the timer for the profiler.
uint | getUpdateDisplayFrequency () const
| Gets the frequency that the Profiler display is updated.
bool | getUseStableMarkers () const
void | logResults ()
| Outputs current profile statistics to the log.
void | markGPUEvent (const String &event)
| Mark a specific, ungrouped, GPU event.
void | removeListener (ProfileSessionListener *listener)
void | reset (bool deleteAll)
| Clears the profiler statistics.
void | setEnabled (bool enabled)
| Sets whether this profiler is enabled.
void | setProfileGroupMask (uint32 mask)
| Set the mask which all profiles must pass to be enabled.
void | setTimer (Timer *t)
| Sets the timer for the profiler.
void | setUpdateDisplayFrequency (uint freq)
| Sets the Profiler so the display of results are updated every n frames.
void | setUseStableMarkers (bool useStableMarkers)
| Sets whether each frame should be tagged with the frame number (starting from 0).
bool | watchForLimit (const String &profileName, Real limit, bool greaterThan=true)
| Returns true if the specified profile goes over or under the given limit frame time.
bool | watchForMax (const String &profileName)
| Returns true if the specified profile reaches a new frame time maximum.
bool | watchForMin (const String &profileName)
| Returns true if the specified profile reaches a new frame time minimum.
Public Member Functions inherited from Ogre::Singleton< Profiler >
| ~Singleton ()

## Static Public Member Functions
static Profiler & | getSingleton ()
| Override standard Singleton retrieval.
static Profiler * | getSingletonPtr ()
| Override standard Singleton retrieval.
Static Public Member Functions inherited from Ogre::Singleton< Profiler >
static Profiler & | getSingleton ()
static Profiler * | getSingletonPtr ()

## Detailed Description

The profiler allows you to measure the performance of your code.

Remarks
  Do not create profiles directly from this unless you want a profile to last outside of its scope (i.e. the main game loop). For most cases, use the macro OgreProfile(name) and braces to limit the scope. You must enable the Profile before you can used it with setEnabled(true). If you want to disable profiling in Ogre, simply set the macro OGRE_PROFILING to 0.

Author
  Amit Mathew (amitmathew (at) yahoo (dot) com)

## Constructor & Destructor Documentation

## ◆ Profiler()

Ogre::Profiler::Profiler | ( |  | ) |

Referenced by getSingleton(), and getSingletonPtr().

## ◆ ~Profiler()

Ogre::Profiler::~Profiler | ( |  | ) |

## Member Function Documentation

## ◆ addListener()

void Ogre::Profiler::addListener | ( | ProfileSessionListener * | listener | ) |

Remarks
  Register a ProfileSessionListener from the Profiler

Parameters

  listener | A valid listener derived class

## ◆ beginGPUEvent()

void Ogre::Profiler::beginGPUEvent | ( | const String & | event | ) |

Mark the beginning of a GPU event group.

Remarks
  Can be safely called in the middle of the profile.

## ◆ beginGPUSample()

void Ogre::Profiler::beginGPUSample | ( | const String & | name,
|  | uint32 * | hashCache )

## ◆ beginProfile()

void Ogre::Profiler::beginProfile | ( | const String & | profileName,
|  | uint32 | groupID = (uint32) OGREPROF_USER_DEFAULT,
|  | ProfileSampleFlags::ProfileSampleFlags | flags = ProfileSampleFlags::FlagsNone )

Begins a profile.

Remarks
  Use the macro OgreProfileBegin(name) instead of calling this directly so that profiling can be ignored in the release version of your app.
  You only use the macro (or this) if you want a profile to last outside of its scope (i.e. the main game loop). If you use this function, make sure you use a corresponding OgreProfileEnd(name). Usually you would use the macro OgreProfile(name). This function will be ignored for a profile that has been disabled or if the profiler is disabled.

Parameters

  profileName | Must be unique and must not be an empty string
  groupID | A profile group identifier, which can allow you to mask profiles

References ProfileSampleFlags::FlagsNone, and Ogre::OGREPROF_USER_DEFAULT.

## ◆ disableProfile()

void Ogre::Profiler::disableProfile | ( | const String & | profileName | ) |

Disables a profile.

Remarks
  Can be safely called in the middle of the profile.

## ◆ enableProfile()

void Ogre::Profiler::enableProfile | ( | const String & | profileName | ) |

Enables a previously disabled profile.

Remarks
  Can be safely called in the middle of the profile.

## ◆ endGPUEvent()

void Ogre::Profiler::endGPUEvent | ( | const String & | event | ) |

Mark the end of a GPU event group.

Remarks
  Can be safely called in the middle of the profile.

## ◆ endGPUSample()

void Ogre::Profiler::endGPUSample | ( | const String & | name | ) |

## ◆ endProfile()

void Ogre::Profiler::endProfile | ( | const String & | profileName,
|  | uint32 | groupID = (uint32) OGREPROF_USER_DEFAULT )

Ends a profile.

Remarks
  Use the macro OgreProfileEnd(name) instead of calling this directly so that profiling can be ignored in the release version of your app.
  This function is usually not called directly unless you want a profile to last outside of its scope. In most cases, using the macro OgreProfile(name) which will call this function automatically when it goes out of scope. Make sure the name of this profile matches its corresponding beginProfile name. This function will be ignored for a profile that has been disabled or if the profiler is disabled.

Parameters

  profileName | Must be unique and must not be an empty string
  groupID | A profile group identifier, which can allow you to mask profiles

References Ogre::OGREPROF_USER_DEFAULT.

## ◆ getEnabled()

bool Ogre::Profiler::getEnabled | ( |  | ) | const

Gets whether this profiler is enabled.

## ◆ getOfflineProfiler()

OfflineProfiler & Ogre::Profiler::getOfflineProfiler | ( |  | ) |
| inline

## ◆ getProfileGroupMask()

uint32 Ogre::Profiler::getProfileGroupMask | ( |  | ) | const
| inline

Get the mask which all profiles must pass to be enabled.

## ◆ getSingleton()

Profiler & Ogre::Profiler::getSingleton | ( |  | ) |
| static

Override standard Singleton retrieval.

Remarks
  Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

  This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

References Profiler().

## ◆ getSingletonPtr()

Profiler * Ogre::Profiler::getSingletonPtr | ( |  | ) |
| static

Override standard Singleton retrieval.

Remarks
  Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

  This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

References Profiler().

## ◆ getTimer()

Timer * Ogre::Profiler::getTimer | ( |  | ) |

Retrieves the timer for the profiler.

## ◆ getUpdateDisplayFrequency()

uint Ogre::Profiler::getUpdateDisplayFrequency | ( |  | ) | const

Gets the frequency that the Profiler display is updated.

## ◆ getUseStableMarkers()

bool Ogre::Profiler::getUseStableMarkers | ( |  | ) | const

## ◆ logResults()

void Ogre::Profiler::logResults | ( |  | ) |

Outputs current profile statistics to the log.

## ◆ markGPUEvent()

void Ogre::Profiler::markGPUEvent | ( | const String & | event | ) |

Mark a specific, ungrouped, GPU event.

Remarks
  Can be safely called in the middle of the profile.

## ◆ removeListener()

void Ogre::Profiler::removeListener | ( | ProfileSessionListener * | listener | ) |

Remarks
  Unregister a ProfileSessionListener from the Profiler

Parameters

  listener | A valid listener derived class

## ◆ reset()

void Ogre::Profiler::reset | ( | bool | deleteAll | ) |

Clears the profiler statistics.

## ◆ setEnabled()

void Ogre::Profiler::setEnabled | ( | bool | enabled | ) |

Sets whether this profiler is enabled.

Only takes effect after the the frame has ended.

Remarks
  When this is called the first time with the parameter true, it initializes the GUI for the Profiler

## ◆ setProfileGroupMask()

void Ogre::Profiler::setProfileGroupMask | ( | uint32 | mask | ) |
| inline

Set the mask which all profiles must pass to be enabled.

## ◆ setTimer()

void Ogre::Profiler::setTimer | ( | Timer * | t | ) |

Sets the timer for the profiler.

## ◆ setUpdateDisplayFrequency()

void Ogre::Profiler::setUpdateDisplayFrequency | ( | uint | freq | ) |

Sets the Profiler so the display of results are updated every n frames.

## ◆ setUseStableMarkers()

void Ogre::Profiler::setUseStableMarkers | ( | bool | useStableMarkers | ) |

Sets whether each frame should be tagged with the frame number (starting from 0).

This is very useful for tagging and identifying CPU samples with GPU ones, but it causes Remotery to shift colours like a rainbow. Setting this to true forces each frame to not have the frame number embedded in it, which stabilizes the colour. Default is false.

Remarks
  Relevant only when using Remotery.

## ◆ watchForLimit()

bool Ogre::Profiler::watchForLimit | ( | const String & | profileName,
|  | Real | limit,
|  | bool | greaterThan = true )

Returns true if the specified profile goes over or under the given limit frame time.

Remarks
  If this is called during a frame, it will be reading the results from the previous frame. Therefore, it is best to use this after the frame has ended.

Parameters

  limit | A number between 0 and 1 representing the percentage of frame time
  greaterThan | If true, this will return whether the limit is exceeded. Otherwise, it will return if the frame time has gone under this limit.

## ◆ watchForMax()

bool Ogre::Profiler::watchForMax | ( | const String & | profileName | ) |

Returns true if the specified profile reaches a new frame time maximum.

Remarks
  If this is called during a frame, it will be reading the results from the previous frame. Therefore, it is best to use this after the frame has ended.

## ◆ watchForMin()

bool Ogre::Profiler::watchForMin | ( | const String & | profileName | ) |

Returns true if the specified profile reaches a new frame time minimum.

Remarks
  If this is called during a frame, it will be reading the results from the previous frame. Therefore, it is best to use this after the frame has ended.

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

- OgreProfiler.h