public |
Inheritance Graph
graph BT
Profiler
click Profiler "classMinSG_1_1Profiling_1_1Profiler"
Description
Profiling code (measure running time, memory consumption and log it)
The profiler manages actions. An action is an extendable object that can be annotated by arbitrary attributes. The profile contains convenience functions to create actions and to annotate some standard attributes. Different loggers can be attached to the profiler that are used to write the actions to streams (e.g. a file, stdout). For example, the profiler can be used to measure the duration and memory consumption of a code section:
MinSG::Profiling::Profiler profiler;
MinSG::Profiling::LoggerPlainText logger(std::cout);
profiler.registerLogger(&logger);
auto prepareAction = profiler.beginTimeMemoryAction("My preparation code");
...
My preparation code
...
profiler.endTimeMemoryAction(prepareAction);
auto executeAction = profiler.beginTimeMemoryAction("My execute code");
...
My execute code
...
profiler.endTimeMemoryAction(executeAction);
profiler.unregisterLogger(&logger);
Public Functions
Profiler() | |
~Profiler() | |
Action | createAction(const std::string & description) const |
void | logAction(const Action & action) const |
void | annotateTime( Action & action, const Util::StringIdentifier & attribute) const |
void | annotateMemory( Action & action, const Util::StringIdentifier & attribute) const |
Action | beginTimeMemoryAction(const std::string & description) const |
void | endTimeMemoryAction( Action & action) const |
void | registerLogger( Logger * output) |
void | unregisterLogger( Logger * output) |
Documentation
function
MinSG::Profiling::Profiler::Profiler
public |
Profiler( | ) |
Defined in MinSG/Ext/Profiling/Profiler.h:64
function
MinSG::Profiling::Profiler::~Profiler
public |
~Profiler( | ) |
Defined in MinSG/Ext/Profiling/Profiler.h:65
function
MinSG::Profiling::Profiler::createAction
public | const |
Action createAction( | const std::string & | description ) const |
Create a new action and set its description.
Parameters
- description
- Human-readable description of the action
Returns
The created action
Defined in MinSG/Ext/Profiling/Profiler.h:73
function
MinSG::Profiling::Profiler::logAction
public | const |
void logAction( | const Action & | action ) const |
Output an action to the associated loggers.
Parameters
- action
- Action that will be logged
Defined in MinSG/Ext/Profiling/Profiler.h:80
function
MinSG::Profiling::Profiler::annotateTime
public | const |
void annotateTime( | Action & | action, |
const Util::StringIdentifier & | attribute | |
) const |
Measure the current time and store it in an attribute of an action.
Parameters
- action
- Action that will be annotated
- attribute
- Attribute name that will be added to the action
Defined in MinSG/Ext/Profiling/Profiler.h:88
function
MinSG::Profiling::Profiler::annotateMemory
public | const |
void annotateMemory( | Action & | action, |
const Util::StringIdentifier & | attribute | |
) const |
Measure the current memory consumption and store it in an attribute of an action.
Parameters
- action
- Action that will be annotated
- attribute
- Attribute name that will be added to the action
Defined in MinSG/Ext/Profiling/Profiler.h:98
function
MinSG::Profiling::Profiler::beginTimeMemoryAction
public | const |
Action beginTimeMemoryAction( | const std::string & | description ) const |
Create a new action, set its description, and store current time and memory consumption of the process.
Parameters
- description
- Human-readable description of the action
Returns
The created action containing time and memory
Defined in MinSG/Ext/Profiling/Profiler.h:108
function
MinSG::Profiling::Profiler::endTimeMemoryAction
public | const |
void endTimeMemoryAction( | Action & | action ) const |
Finish an action. The current time and memory consumption will be stored to allow comparison with the beginning of the action. The action will be logged.
Parameters
- action
- Action that will be annotated and logged
Defined in MinSG/Ext/Profiling/Profiler.h:117
function
MinSG::Profiling::Profiler::registerLogger
public |
void registerLogger( | Logger * | output ) |
Register a logger that will be used to output profiling information. The information will be formatted internally by the logger.
Parameters
- output
- Logger that will be used to write profiling output. The given logger has to stay writeable at least until this object is destroyed or the logger is removed with* unregisterLogger() *.
Defined in MinSG/Ext/Profiling/Profiler.h:127
function
MinSG::Profiling::Profiler::unregisterLogger
public |
void unregisterLogger( | Logger * | output ) |
Remove the registered logger.
Parameters
- output
- Logger that will be removed
Defined in MinSG/Ext/Profiling/Profiler.h:134