The PerformanceMonitor class provides an easy to use tool for performance measurement. More...
#include <PerformanceMonitor.h>
Static Public Member Functions | |
static void | addData (std::string name, double data, std::string prefix) |
addData Manually insert a time measurement with given identifier More... | |
static void | addNonTimeData (std::string name, double data, std::string prefix) |
addNonTimeData Adds some additional arbitrary information. In contrast to addStaticData multiple values (measurements) can be passed to the same identifier. However, right now they are output as if they were time measurements. More... | |
static void | addStaticData (std::string name, double data, std::string prefix) |
addStaticData Adds static information. You can basically put any information that can be cast into a double in here. More... | |
static void | disablePrefix (std::string prefix) |
disablePrefix Disables a given prefix More... | |
static void | enableAll (const bool &enabled) |
enableAll set whether all prefixes should be enabled or not. Overrides single enable/disable assignments. More... | |
static void | enablePrefix (std::string prefix) |
enablePrefix Enables a given prefix More... | |
static PerformanceMonitor * | getInstance () |
getInstance As The Performance Monitor is implemented as a singleton pattern, this provides an accessor to the PM instance. If there's no instance, yet, one will be created. More... | |
static void | initialize (const uint32_t num_names, const uint32_t num_events) |
initialize Initialize the performance monitor. Call this before using anything from PerformanceMonitor More... | |
static double | measurement (std::string timer_name, std::string description, std::string prefix="", logging::LogLevel level=icl_core::logging::eLL_INFO) |
measurement Make a measurement from a given timer. The timer will keep running and the measurement will be added to PM's event log under the given description. More... | |
static void | printSummary (std::string prefix, std::string name, icl_core::logging::LogLevel level=icl_core::logging::eLL_INFO) |
printSummary Print a summary for a given collection of events. More... | |
static void | printSummaryAll (icl_core::logging::LogLevel level=icl_core::logging::eLL_INFO) |
printSummaryAll Print summary of everything: All prefixes, all descriptions and all static data. Output will be sorted by prefixes and static data will be printed first. More... | |
static void | printSummaryFromPrefix (std::string prefix, icl_core::logging::LogLevel level=icl_core::logging::eLL_INFO) |
printSummaryFromPrefix Prints summary for the given prefix only. More... | |
static void | start (std::string timer_name) |
start Start a timer with the given identifier More... | |
static double | startStop (std::string timer_name, std::string description, std::string prefix="", logging::LogLevel level=icl_core::logging::eLL_INFO) |
measurement Make a measurement from a given timer. Resets the timer and the measurement will be added to PM's event log under the given description. If the given timer isn't started yet, it just will be started. More... | |
Public Attributes | |
bool | m_enabled |
if set to false, the performance monitor will be non-operational More... | |
bool | m_print_stop |
if set to false, the performance monitor won't print measurement events More... | |
Protected Member Functions | |
void | addEvent (std::string prefix, std::string name, double data) |
add event to the event map More... | |
void | addNonTimeEvent (std::string prefix, std::string name, double data) |
void | createStatisticSummary (std::stringstream &ss, std::string prefix, std::string name) |
Create output string for summary. More... | |
void | createStatisticSummaryNonTime (std::stringstream &ss, std::string prefix, std::string name) |
double | getAverage (std::string name) |
calculate the average of all events with description name More... | |
double | getAverageNonTime (std::string name) |
void | getMedian (std::string name, double &median, double &min, double &max) |
calculate the median of all events with description name More... | |
void | getMedianNonTime (std::string name, double &median, double &min, double &max) |
bool | isEnabled (std::string prefix) |
check if prefix is enabled More... | |
PerformanceMonitor () | |
constructor More... | |
void | print (std::string message, icl_core::logging::LogLevel level=icl_core::logging::eLL_DEBUG) |
prints the given message to the specified log level More... | |
~PerformanceMonitor () | |
destructor More... | |
Protected Attributes | |
bool | m_all_enabled |
std::vector< std::vector< double > > | m_buffer |
std::map< std::string, std::vector< double > > | m_data |
std::map< std::string, std::vector< double > > | m_data_nontime |
std::map< std::string, bool > | m_enabled_prefix |
std::map< std::string, double > | m_static_data |
std::map< std::string, TimeStamp > | m_timer |
Static Private Attributes | |
static PerformanceMonitor * | m_instance = NULL |
The PerformanceMonitor class provides an easy to use tool for performance measurement.
You can use the static methods directly, but using the macros defined in PerformanceMonitorMacros.h is recommended, as they provide enabling and disabling by defines such as IC_DEBUG and IC_PERFORMANCE_MONITOR.
The typical minimum workflow would look like follows:
By default all outputs go to the prefix "". You can enable other prefixes as you wish and then use the print and summary functions with these prefixes. This way you can easily turn different groups on and off.
Static information such as parallel configurations can be passed to the performance monitor as well, which will be printed in the summary, as well.
Definition at line 69 of file PerformanceMonitor.h.
|
protected |
constructor
Definition at line 44 of file PerformanceMonitor.cpp.
|
protected |
destructor
Definition at line 51 of file PerformanceMonitor.cpp.
|
static |
addData Manually insert a time measurement with given identifier
name | Timer description |
data | Time |
prefix | Prefix that the data belongs to. |
Definition at line 161 of file PerformanceMonitor.cpp.
|
protected |
add event to the event map
Definition at line 177 of file PerformanceMonitor.cpp.
|
static |
addNonTimeData Adds some additional arbitrary information. In contrast to addStaticData multiple values (measurements) can be passed to the same identifier. However, right now they are output as if they were time measurements.
name | Short data description |
data | The data itself |
prefix | Prefix that the data belongs to. |
Definition at line 169 of file PerformanceMonitor.cpp.
|
protected |
Definition at line 195 of file PerformanceMonitor.cpp.
|
static |
addStaticData Adds static information. You can basically put any information that can be cast into a double in here.
name | Description of the data |
data | The data itself |
prefix | Prefix that the data belongs to. |
Definition at line 152 of file PerformanceMonitor.cpp.
|
protected |
Create output string for summary.
Definition at line 241 of file PerformanceMonitor.cpp.
|
protected |
Definition at line 256 of file PerformanceMonitor.cpp.
|
static |
disablePrefix Disables a given prefix
prefix | Prefix that will be disabled. |
Definition at line 296 of file PerformanceMonitor.cpp.
|
static |
enableAll set whether all prefixes should be enabled or not. Overrides single enable/disable assignments.
Once enableAll(false) is called, single enable/disables statements will be used again.
Definition at line 291 of file PerformanceMonitor.cpp.
|
static |
enablePrefix Enables a given prefix
prefix | Prefix that will be enabled. |
Definition at line 281 of file PerformanceMonitor.cpp.
|
protected |
calculate the average of all events with description name
Definition at line 377 of file PerformanceMonitor.cpp.
|
protected |
Definition at line 388 of file PerformanceMonitor.cpp.
|
static |
getInstance As The Performance Monitor is implemented as a singleton pattern, this provides an accessor to the PM instance. If there's no instance, yet, one will be created.
Definition at line 56 of file PerformanceMonitor.cpp.
|
protected |
calculate the median of all events with description name
Definition at line 399 of file PerformanceMonitor.cpp.
|
protected |
Definition at line 408 of file PerformanceMonitor.cpp.
|
static |
initialize Initialize the performance monitor. Call this before using anything from PerformanceMonitor
num_names | Assumed maximum number of event names (descriptions). This serves as preallocation of the according map. |
num_events | Assumed maximum number of events (timer measurements). This serves as preallocation of the according map. |
Definition at line 65 of file PerformanceMonitor.cpp.
|
protected |
check if prefix is enabled
Definition at line 78 of file PerformanceMonitor.cpp.
|
static |
measurement Make a measurement from a given timer. The timer will keep running and the measurement will be added to PM's event log under the given description.
timer_name | The timer's identifier |
description | The event description. Keep it short for better readability. |
prefix | Optional prefix to put the event into a group. Defaults to "" |
level | Optional logging level. Defaults to icl_core::logging::eLL_INFO |
Definition at line 92 of file PerformanceMonitor.cpp.
|
protected |
prints the given message to the specified log level
Definition at line 214 of file PerformanceMonitor.cpp.
|
static |
printSummary Print a summary for a given collection of events.
prefix | The prefix in which the events lie. |
name | The events' description |
level | Optional logging level. Defaults to icl_core::logging::eLL_INFO |
Definition at line 271 of file PerformanceMonitor.cpp.
|
static |
printSummaryAll Print summary of everything: All prefixes, all descriptions and all static data. Output will be sorted by prefixes and static data will be printed first.
level | Optional logging level. Defaults to icl_core::logging::eLL_INFO |
Definition at line 306 of file PerformanceMonitor.cpp.
|
static |
printSummaryFromPrefix Prints summary for the given prefix only.
prefix | Prefix for which the summary will be printed |
level | Optional logging level. Defaults to icl_core::logging::eLL_INFO |
Definition at line 317 of file PerformanceMonitor.cpp.
|
static |
start Start a timer with the given identifier
timer_name | The timer's identifier |
Definition at line 83 of file PerformanceMonitor.cpp.
|
static |
measurement Make a measurement from a given timer. Resets the timer and the measurement will be added to PM's event log under the given description. If the given timer isn't started yet, it just will be started.
timer_name | The timer's identifier |
description | The event description. Keep it short for better readability. |
prefix | Optional prefix to put the event into a group. Defaults to "" |
level | Optional logging level. Defaults to icl_core::logging::eLL_INFO |
Definition at line 114 of file PerformanceMonitor.cpp.
|
protected |
Definition at line 234 of file PerformanceMonitor.h.
|
protected |
Definition at line 230 of file PerformanceMonitor.h.
|
protected |
Definition at line 227 of file PerformanceMonitor.h.
|
protected |
Definition at line 228 of file PerformanceMonitor.h.
bool icl_core::perf_mon::PerformanceMonitor::m_enabled |
if set to false, the performance monitor will be non-operational
Definition at line 194 of file PerformanceMonitor.h.
|
protected |
Definition at line 231 of file PerformanceMonitor.h.
|
staticprivate |
Definition at line 238 of file PerformanceMonitor.h.
bool icl_core::perf_mon::PerformanceMonitor::m_print_stop |
if set to false, the performance monitor won't print measurement events
Definition at line 196 of file PerformanceMonitor.h.
|
protected |
Definition at line 232 of file PerformanceMonitor.h.
|
protected |
Definition at line 229 of file PerformanceMonitor.h.