Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
nirt::IProfiler Class Referenceabstract

Code-profiler. Please check the example in the Nirtcpp examples folder about how to use it. More...

#include <nirtcpp/core/engine/IProfiler.hpp>

Collaboration diagram for nirt::IProfiler:
Collaboration graph

Public Member Functions

 IProfiler ()
 Constructor. You could use this to create a new profiler, but usually getProfiler() is used to access the global instance.
 
void add (s32 id, const core::stringw &name, const core::stringw &groupName)
 Add an id with given name and group which can be used for profiling with start/stop.
 
s32 add (const core::stringw &name, const core::stringw &groupName)
 Add an automatically generated for the given name and group which can be used for profiling with start/stop.
 
u32 getProfileDataCount () const
 Return the number of profile data blocks. There is one for each id.
 
bool findDataIndex (u32 &result, const core::stringw &name) const
 Search for the index of the profile data by name.
 
const SProfileDatagetProfileDataByIndex (u32 index) const
 Get the profile data.
 
const SProfileDatagetProfileDataById (u32 id)
 Get the profile data.
 
u32 getGroupCount () const
 Get the number of profile groups. Will be at least 1.
 
const SProfileDatagetGroupData (u32 index) const
 Get profile data for a group.
 
bool findGroupIndex (u32 &result, const core::stringw &name) const
 Find the group index by the group-name.
 
void start (s32 id)
 Start profile-timing for the given id.
 
void stop (s32 id)
 Stop profile-timing for the given id.
 
void resetDataById (s32 id)
 Reset profile data for the given id.
 
void resetDataByIndex (u32 index)
 Reset profile data for the given index.
 
void resetGroup (u32 index)
 Reset profile data for a whole group.
 
void resetAll ()
 Reset all profile data.
 
virtual void printAll (core::stringw &result, bool includeOverview=false, bool suppressUncalled=true) const =0
 Write all profile-data into a string.
 
virtual void printGroup (core::stringw &result, u32 groupIndex, bool suppressUncalled) const =0
 Write the profile data of one group into a string.
 

Protected Member Functions

u32 addGroup (const core::stringw &name)
 

Protected Attributes

ITimerTimer
 
core::array< SProfileDataProfileDatas
 
core::array< SProfileDataProfileGroups
 

Detailed Description

Code-profiler. Please check the example in the Nirtcpp examples folder about how to use it.

Member Function Documentation

◆ add() [1/2]

s32 nirt::IProfiler::add ( const core::stringw name,
const core::stringw groupName 
)
inline

Add an automatically generated for the given name and group which can be used for profiling with start/stop.

After calling this once you can start/stop profiling with the returned id.

Parameters
nameName for displaying profile data.
groupNameEach id belongs into a group - this helps on displaying profile data.
Returns
Automatic id's start at INT_MAX and count down for each new id. If the name already has an id then that id will be returned.

◆ add() [2/2]

void nirt::IProfiler::add ( s32  id,
const core::stringw name,
const core::stringw groupName 
)
inline

Add an id with given name and group which can be used for profiling with start/stop.

After calling this once you can start/stop profiling for the given id.

Parameters
idShould be >= 0 as negative id's are reserved for Nirtcpp. Also very large numbers (near INT_MAX) might have been added automatically by the other add function.
nameName for displaying profile data.
groupNameEach id belongs into a group - this helps on displaying profile data.

◆ findDataIndex()

bool nirt::IProfiler::findDataIndex ( u32 result,
const core::stringw name 
) const
inline

Search for the index of the profile data by name.

Parameters
resultReceives the resulting data index when one was found.
nameString with name to search for
Returns
true when found, false when not found

◆ findGroupIndex()

bool nirt::IProfiler::findGroupIndex ( u32 result,
const core::stringw name 
) const
inline

Find the group index by the group-name.

Parameters
resultReceives the resulting group index when one was found.
nameString with name to search for
Returns
true when found, false when not found

◆ getGroupCount()

u32 nirt::IProfiler::getGroupCount ( ) const
inline

Get the number of profile groups. Will be at least 1.

NOTE: The first groups is always L"overview" which is an overview for all existing groups

◆ getGroupData()

const SProfileData & nirt::IProfiler::getGroupData ( u32  index) const
inline

Get profile data for a group.

NOTE: The first groups is always L"overview" which is an overview for all existing groups

◆ getProfileDataById()

const SProfileData * nirt::IProfiler::getProfileDataById ( u32  id)
inline

Get the profile data.

Parameters
idSame value as used in add
Returns
Profile data for the given id or 0 when it does not exist.

◆ getProfileDataByIndex()

const SProfileData & nirt::IProfiler::getProfileDataByIndex ( u32  index) const
inline

Get the profile data.

Parameters
indexA value between 0 and getProfileDataCount()-1. Indices can change when new id's are added.

◆ printAll()

virtual void nirt::IProfiler::printAll ( core::stringw result,
bool  includeOverview = false,
bool  suppressUncalled = true 
) const
pure virtual

Write all profile-data into a string.

Parameters
resultReceives the result string.
includeOverviewWhen true a group-overview is attached first
suppressUncalledWhen true elements which got never called are not printed

◆ printGroup()

virtual void nirt::IProfiler::printGroup ( core::stringw result,
u32  groupIndex,
bool  suppressUncalled 
) const
pure virtual

Write the profile data of one group into a string.

Parameters
resultReceives the result string.
groupIndex_

◆ resetAll()

void nirt::IProfiler::resetAll ( )
inline

Reset all profile data.

NOTE: This is not deleting id's or groups, just resetting all timers to 0.

◆ start()

void nirt::IProfiler::start ( s32  id)
inline

Start profile-timing for the given id.

This increases an internal run-counter for the given id. It will profile as long as that counter is > 0. NOTE: you have to add the id first with one of the add functions

◆ stop()

void nirt::IProfiler::stop ( s32  id)
inline

Stop profile-timing for the given id.

This increases an internal run-counter for the given id. If it reaches 0 the time since start is recorded. You should have the same amount of start and stop calls. If stop is called more often than start then the additional stop calls will be ignored (counter never goes below 0)


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

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print