kanzi::MainLoopTaskProfiler Class Reference

Profiles the execution time of main loop tasks. More...

#include <kanzi/core/profiling/main_loop_task_profiler.hpp>

Inheritance diagram for kanzi::MainLoopTaskProfiler:
kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics > kanzi::AbstractProfiler

Public Types

typedef AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatisticsBaseValueProfiler
 The typedef of the base value profiler class. More...
 
- Public Types inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
typedef function< void(AbstractValueProfiler &)> FullBufferCallback
 The typedef used for full buffer callback. More...
 
typedef weak_ptr< void > FullBufferCallbackHandle
 The typedef used for full buffer callback handle. More...
 
- Public Types inherited from kanzi::AbstractProfiler
enum  DataType {
  DataTypeNotDefined, DataTypeBoolean, DataTypeUint64, DataTypeFloat,
  DataTypeString
}
 Supported profiling data field value types. More...
 
typedef variant< monostate, bool, uint64_t, float, string > Value
 Container for profiling data field value. More...
 

Public Member Functions

void addSample (MainLoopTaskProfilerSampleData sample)
 Adds a new profiling data sample to the profiler. More...
 
void resetSampleData ()
 Resets sample data. More...
 
const MainLoopTaskProfilerSampleDatagetSample (size_t index) const
 Accesses a profiling data sample stored in the sample buffer. More...
 
const IntervalProfilerSampleStatisticsgetProfilingStatistics () const
 Gets a reference to main loop task profiling statistics. More...
 
- Public Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
FullBufferCallbackHandle addFullBufferCallback (FullBufferCallback callback)
 Adds a new full buffer callback. More...
 
void removeFullBufferCallback (const FullBufferCallbackHandle &callbackHandle)
 Removes a full buffer callback. More...
 
void resetSampleData ()
 Resets the aggregate profiling data and sample buffer. More...
 
- Public Member Functions inherited from kanzi::AbstractProfiler
virtual ~AbstractProfiler ()
 Destructor. More...
 
string_view getName () const
 Gets the name of the profiler. More...
 
const ProfilingCategorygetCategory () const
 Gets a reference to the profiling category assigned to the profiler. More...
 
size_t getAggregateDataFieldCount () const
 Gets the number of aggregate data fields. More...
 
string getAggregateDataFieldName (size_t fieldIndex) const
 Gets the name of an aggregate data field. More...
 
Value getAggregateDataFieldValue (size_t fieldIndex) const
 Gets the value of an aggregate profiling data field. More...
 
size_t getSampleFieldCount () const
 Gets the number of sample data fields. More...
 
string getSampleFieldName (size_t fieldIndex) const
 Gets the name of a data sample field. More...
 
size_t getSampleCount () const
 Gets the number of collected profiling data samples. More...
 
Value getSampleFieldValue (size_t sampleIndex, size_t fieldIndex) const
 Gets the value of a profiling data sample field. More...
 
void logAggregateData () const
 Logs aggregate profiling data. More...
 
void logAllData () const
 Logs all profiling data. More...
 

Static Public Member Functions

static MainLoopTaskProfilerSharedPtr create (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Creates a new main loop task profiler. More...
 
- Static Public Member Functions inherited from kanzi::AbstractProfiler
static DataType getDataType (const Value &value)
 Gets the type of the data stored in a profiling data field. More...
 

Protected Member Functions

 MainLoopTaskProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor. More...
 
 MainLoopTaskProfiler (const MainLoopTaskProfiler &rhs) KZ_DELETED_FUNCTION
 Deleted copy constructor, preventing copying of the object. More...
 
MainLoopTaskProfileroperator= (const MainLoopTaskProfiler &rhs) KZ_DELETED_FUNCTION
 Deleted assignment operator, preventing assignment of the object. More...
 
virtual size_t getAggregateDataFieldCountOverride () const KZ_OVERRIDE
 The override of AbstractProfiler::getAggregateDataFieldCountOverride(). More...
 
virtual string getAggregateDataFieldNameOverride (size_t fieldIndex) const KZ_OVERRIDE
 The override of AbstractProfiler::getAggregateDataFieldNameOverride(). More...
 
virtual size_t getSampleFieldCountOverride () const KZ_OVERRIDE
 The override of AbstractProfiler::getSampleFieldCountOverride(). More...
 
virtual string getSampleFieldNameOverride (size_t fieldIndex) const KZ_OVERRIDE
 The override of AbstractProfiler::getSampleFieldNameOverride(). More...
 
virtual Value getAggregateDataFieldValueOverride (size_t fieldIndex) const KZ_OVERRIDE
 The override of AbstractProfiler::getAggregateDataFieldValueOverride(). More...
 
virtual Value getSampleFieldValueOverride (size_t sampleIndex, size_t fieldIndex) const KZ_OVERRIDE
 The override of AbstractProfiler::getSampleFieldValueOverride(). More...
 
- Protected Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
 AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor. More...
 
const MainLoopTaskProfilerSampleDatagetSample (size_t index) const
 Accesses a profiling data sample stored in the sample buffer. More...
 
void checkBufferFull ()
 Performs all buffer full callbacks and clears samples if buffer is full. More...
 
void addSample (const MainLoopTaskProfilerSampleData &sample)
 Adds a new profiling data sample. More...
 
void addSample (KZ_RV_REF(MainLoopTaskProfilerSampleData) sample)
 Adds a new movable profiling data sample to the profiler. More...
 
virtual size_t getSampleCountOverride () const KZ_OVERRIDE
 Override of #AbstractProfiler::getSampleCountOverride(). More...
 
- Protected Member Functions inherited from kanzi::AbstractProfiler
 AbstractProfiler (string_view name, const ProfilingCategory &category)
 Constructor. More...
 
virtual void logAggregateDataOverride () const
 To implement your own logging of aggregate profiling data, override this function in the derived profiler class. More...
 
virtual void logAllDataOverride () const
 To implement your own logging of all profiling data, override this function in the derived profiler class. More...
 

Additional Inherited Members

- Protected Types inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
typedef MainLoopTaskProfilerSampleData SampleDataType
 The sample data type typedef used in derived classes. More...
 
typedef IntervalProfilerSampleStatistics AggregateProfilingDataType
 The aggregate profiling data type typedef used in derived classes. More...
 
typedef shared_ptr< FullBufferCallbackFullBufferCallbackSharedPtr
 The typedef used for shared pointer to full buffer callback. More...
 
typedef vector< FullBufferCallbackSharedPtrFullBufferCallbackContainer
 The typedef used for container of full buffer callback shared pointers. More...
 
- Static Protected Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
static void invokeBufferFullCallback (AbstractValueProfiler &profiler, FullBufferCallbackSharedPtr &callback)
 Internal helper function used by checkBufferFull. More...
 
- Protected Attributes inherited from kanzi::AbstractValueProfiler< MainLoopTaskProfilerSampleData, IntervalProfilerSampleStatistics >
IntervalProfilerSampleStatistics m_aggregateProfilingData
 The aggregate profiling data. More...
 

Detailed Description

Profiles the execution time of main loop tasks.

The main loop task profiler collects samples of type MainLoopTaskProfilerSampleData, which include information about interval duration, start point, and main loop counter identifying the main loop iteration when the interval was measured.

For details on the information included in the sample, see MainLoopTaskProfilerSampleData. For an example of how the profiling sample is collected in main loop task profiling, see MainLoopTaskProfilingSampler.

The MainLoopTaskProfilerSampleData keeps samples in a circular sample buffer. Every time a new sample is added to the profiler, the statistics data is updated. To access the statistics data, use getProfilingStatistics().

Member Typedef Documentation

Constructor & Destructor Documentation

kanzi::MainLoopTaskProfiler::MainLoopTaskProfiler ( string_view  name,
const ProfilingCategory category,
size_t  sampleBufferSize 
)
explicitprotected

Constructor.

Parameters
nameThe name of the profiler.
categoryThe category assigned to the profiler.
sampleBufferSizeThe maximum size of the sample buffer.
kanzi::MainLoopTaskProfiler::MainLoopTaskProfiler ( const MainLoopTaskProfiler rhs)
explicitprotected

Deleted copy constructor, preventing copying of the object.

Member Function Documentation

static MainLoopTaskProfilerSharedPtr kanzi::MainLoopTaskProfiler::create ( string_view  name,
const ProfilingCategory category,
size_t  sampleBufferSize 
)
static

Creates a new main loop task profiler.

Parameters
nameThe name of the new profiler.
categoryThe profiling category assigned to the profiler.
sampleBufferSizeThe maximum size of the profiling sample buffer.
Returns
The unique pointer to the new profiler.
void kanzi::MainLoopTaskProfiler::addSample ( MainLoopTaskProfilerSampleData  sample)

Adds a new profiling data sample to the profiler.

Parameters
sampleThe profiling data sample.
void kanzi::MainLoopTaskProfiler::resetSampleData ( )

Resets sample data.

Clears sample buffer and resets sample statistics.

const MainLoopTaskProfilerSampleData& kanzi::MainLoopTaskProfiler::getSample ( size_t  index) const
inline

Accesses a profiling data sample stored in the sample buffer.

Parameters
indexThe index of the sample.
Returns
The profiling data sample.
const IntervalProfilerSampleStatistics& kanzi::MainLoopTaskProfiler::getProfilingStatistics ( ) const
inline

Gets a reference to main loop task profiling statistics.

Returns
The reference to main loop task profiling statistics.
MainLoopTaskProfiler& kanzi::MainLoopTaskProfiler::operator= ( const MainLoopTaskProfiler rhs)
protected

Deleted assignment operator, preventing assignment of the object.

virtual size_t kanzi::MainLoopTaskProfiler::getAggregateDataFieldCountOverride ( ) const
protectedvirtual

The override of AbstractProfiler::getAggregateDataFieldCountOverride().

Returns
The number of aggregate data fields.

Implements kanzi::AbstractProfiler.

virtual string kanzi::MainLoopTaskProfiler::getAggregateDataFieldNameOverride ( size_t  fieldIndex) const
protectedvirtual

The override of AbstractProfiler::getAggregateDataFieldNameOverride().

Parameters
fieldIndexThe index of the field.
Returns
The number of aggregate data fields.

Implements kanzi::AbstractProfiler.

virtual size_t kanzi::MainLoopTaskProfiler::getSampleFieldCountOverride ( ) const
protectedvirtual

The override of AbstractProfiler::getSampleFieldCountOverride().

Returns
The number of sample data fields.

Implements kanzi::AbstractProfiler.

virtual string kanzi::MainLoopTaskProfiler::getSampleFieldNameOverride ( size_t  fieldIndex) const
protectedvirtual

The override of AbstractProfiler::getSampleFieldNameOverride().

Parameters
fieldIndexThe index of the sample field.
Returns
The name of the sample field.

Implements kanzi::AbstractProfiler.

virtual Value kanzi::MainLoopTaskProfiler::getAggregateDataFieldValueOverride ( size_t  fieldIndex) const
protectedvirtual

The override of AbstractProfiler::getAggregateDataFieldValueOverride().

Parameters
fieldIndexThe index of the aggregate profiling data field.
Returns
The value of the aggregate profiling data field.

Implements kanzi::AbstractProfiler.

virtual Value kanzi::MainLoopTaskProfiler::getSampleFieldValueOverride ( size_t  sampleIndex,
size_t  fieldIndex 
) const
protectedvirtual

The override of AbstractProfiler::getSampleFieldValueOverride().

Parameters
sampleIndexThe index of the profiling data sample.
fieldIndexThe index of the profiling data sample field.
Returns
The value of the profiling data sample field.

Implements kanzi::AbstractProfiler.


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