Kanzi  3.9.4
Kanzi Engine API
kanzi::NamedIntervalProfiler Class Reference

The named interval profiler. More...

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

Inheritance diagram for kanzi::NamedIntervalProfiler:
[legend]

Public Types

using BaseValueProfiler = AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
 The typedef of the base value profiler class. More...
 
- Public Types inherited from kanzi::AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
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, DataTypeCount
}
 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 (const NamedIntervalProfilerSampleData &sample)
 Adds a new profiling data sample to the profiler. More...
 
const NamedIntervalProfilerSampleStatisticsgetProfilingStatistics () const
 Gets a reference to interval profiling statistics. More...
 
const NamedIntervalProfilerSampleDatagetSample (size_t index) const
 Accesses a profiling data sample stored in the sample buffer. More...
 
- Public Member Functions inherited from kanzi::AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
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
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...
 
const ProfilingCategorygetCategory () const
 Gets a reference to the profiling category assigned to the profiler. More...
 
string_view getName () const
 Gets the name of the profiler. More...
 
size_t getSampleCount () const
 Gets the number of collected profiling data samples. More...
 
size_t getSampleFieldCount () const
 Gets the number of sample data fields. More...
 
DataType getSampleFieldDataType (size_t fieldIndex) const
 Gets the data type of a data sample field. More...
 
string getSampleFieldName (size_t fieldIndex) const
 Gets the name of a data sample field. 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...
 
virtual ~AbstractProfiler ()
 Destructor. More...
 

Static Public Member Functions

static NamedIntervalProfilerSharedPtr create (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Creates a new 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

size_t getAggregateDataFieldCountOverride () const override
 The override of AbstractProfiler::getAggregateDataFieldCountOverride(). More...
 
string getAggregateDataFieldNameOverride (size_t fieldIndex) const override
 The override of AbstractProfiler::getAggregateDataFieldNameOverride(). More...
 
Value getAggregateDataFieldValueOverride (size_t fieldIndex) const override
 The override of AbstractProfilerRegistry::getAggregateDataFieldValueOverride(). More...
 
size_t getSampleFieldCountOverride () const override
 The override of AbstractProfiler::getSampleFieldCountOverride(). More...
 
DataType getSampleFieldDataTypeOverride (size_t fieldIndex) const override
 The override of AbstractProfiler::getSampleFieldDataTypeOverride(). More...
 
string getSampleFieldNameOverride (size_t fieldIndex) const override
 The override of AbstractProfiler::getSampleFieldNameOverride(). More...
 
Value getSampleFieldValueOverride (size_t sampleIndex, size_t fieldIndex) const override
 The override of AbstractProfilerRegistry::getSampleFieldValueOverride(). More...
 
 NamedIntervalProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor. More...
 
 NamedIntervalProfiler (const NamedIntervalProfiler &rhs)=delete
 Deleted copy constructor, preventing copying of the object. More...
 
NamedIntervalProfileroperator= (const NamedIntervalProfiler &rhs)=delete
 Deleted assignment operator, preventing assignment of the object. More...
 
- Protected Member Functions inherited from kanzi::AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
 AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor. More...
 
void addSample (const NamedIntervalProfilerSampleData &sample)
 Adds a new profiling data sample. More...
 
void addSample (NamedIntervalProfilerSampleData &&sample)
 Adds a new movable profiling data sample to the profiler. More...
 
void checkBufferFull ()
 Performs all buffer full callbacks and clears samples if buffer is full. More...
 
const NamedIntervalProfilerSampleDatagetSample (size_t index) const
 Accesses a profiling data sample stored in the sample buffer. More...
 
size_t getSampleCountOverride () const override
 Override of AbstractProfiler::getSampleCountOverride(). More...
 
void resetSampleBufferSize (size_t sampleBufferSize)
 Resets the size of the sample buffer. 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< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
typedef NamedIntervalProfilerSampleStatistics AggregateProfilingDataType
 The aggregate profiling data type typedef used in derived classes. More...
 
typedef vector< FullBufferCallbackSharedPtrFullBufferCallbackContainer
 The typedef used for container of full buffer callback shared pointers. More...
 
typedef shared_ptr< FullBufferCallbackFullBufferCallbackSharedPtr
 The typedef used for shared pointer to full buffer callback. More...
 
typedef NamedIntervalProfilerSampleData SampleDataType
 The sample data type typedef used in derived classes. More...
 
- Static Protected Member Functions inherited from kanzi::AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
static void invokeBufferFullCallback (AbstractValueProfiler &profiler, FullBufferCallbackSharedPtr &callback)
 Internal helper function used by checkBufferFull. More...
 
- Protected Attributes inherited from kanzi::AbstractValueProfiler< NamedIntervalProfilerSampleData, NamedIntervalProfilerSampleStatistics >
NamedIntervalProfilerSampleStatistics m_aggregateProfilingData
 The aggregate profiling data. More...
 
FullBufferCallbackContainer m_fullBufferCallbacks
 The container of buffer full callbacks. More...
 
circular_buffer< NamedIntervalProfilerSampleDatam_sampleBuffer
 The profiling data sample buffer. More...
 

Detailed Description

The named interval profiler.

Use Profiling macros to profile codepath execution time.

The interval profiler collects samples of NamedIntervalProfilerSampleData type which include information about interval duration, start point, and extra contextual information about the object that is being operated on. For details on the information included in the sample, see NamedIntervalProfilerSampleData. For an example of how interval profiling sample is collected in scope profiling, see NamedIntervalProfilerSampler.

To add the collected sample to the profiler, use the addSample() function.

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

Member Typedef Documentation

◆ BaseValueProfiler

Constructor & Destructor Documentation

◆ NamedIntervalProfiler() [1/2]

kanzi::NamedIntervalProfiler::NamedIntervalProfiler ( 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.

◆ NamedIntervalProfiler() [2/2]

kanzi::NamedIntervalProfiler::NamedIntervalProfiler ( const NamedIntervalProfiler rhs)
protecteddelete

Deleted copy constructor, preventing copying of the object.

Member Function Documentation

◆ create()

static NamedIntervalProfilerSharedPtr kanzi::NamedIntervalProfiler::create ( string_view  name,
const ProfilingCategory category,
size_t  sampleBufferSize 
)
static

Creates a new 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 NamedIntervalProfilerSharedPtr pointing to new profiler.

◆ addSample()

void kanzi::NamedIntervalProfiler::addSample ( const NamedIntervalProfilerSampleData sample)

Adds a new profiling data sample to the profiler.

Parameters
sampleThe profiling data sample.

◆ getSample()

const NamedIntervalProfilerSampleData& kanzi::NamedIntervalProfiler::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.

◆ getProfilingStatistics()

const NamedIntervalProfilerSampleStatistics& kanzi::NamedIntervalProfiler::getProfilingStatistics ( ) const
inline

Gets a reference to interval profiling statistics.

Returns
The reference to interval profiling statistics.

◆ operator=()

NamedIntervalProfiler& kanzi::NamedIntervalProfiler::operator= ( const NamedIntervalProfiler rhs)
protecteddelete

Deleted assignment operator, preventing assignment of the object.

◆ getAggregateDataFieldCountOverride()

size_t kanzi::NamedIntervalProfiler::getAggregateDataFieldCountOverride ( ) const
overrideprotectedvirtual

The override of AbstractProfiler::getAggregateDataFieldCountOverride().

Returns
The number of aggregate data fields.

Implements kanzi::AbstractProfiler.

◆ getAggregateDataFieldNameOverride()

string kanzi::NamedIntervalProfiler::getAggregateDataFieldNameOverride ( size_t  fieldIndex) const
overrideprotectedvirtual

The override of AbstractProfiler::getAggregateDataFieldNameOverride().

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

Implements kanzi::AbstractProfiler.

◆ getSampleFieldCountOverride()

size_t kanzi::NamedIntervalProfiler::getSampleFieldCountOverride ( ) const
overrideprotectedvirtual

The override of AbstractProfiler::getSampleFieldCountOverride().

Returns
The number of sample data fields.

Implements kanzi::AbstractProfiler.

◆ getSampleFieldNameOverride()

string kanzi::NamedIntervalProfiler::getSampleFieldNameOverride ( size_t  fieldIndex) const
overrideprotectedvirtual

The override of AbstractProfiler::getSampleFieldNameOverride().

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

Implements kanzi::AbstractProfiler.

◆ getSampleFieldDataTypeOverride()

DataType kanzi::NamedIntervalProfiler::getSampleFieldDataTypeOverride ( size_t  fieldIndex) const
overrideprotectedvirtual

The override of AbstractProfiler::getSampleFieldDataTypeOverride().

Parameters
fieldIndexThe index of the field.
Returns
The data type of sample field.

Implements kanzi::AbstractProfiler.

◆ getAggregateDataFieldValueOverride()

Value kanzi::NamedIntervalProfiler::getAggregateDataFieldValueOverride ( size_t  fieldIndex) const
overrideprotectedvirtual

The override of AbstractProfilerRegistry::getAggregateDataFieldValueOverride().

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

Implements kanzi::AbstractProfiler.

◆ getSampleFieldValueOverride()

Value kanzi::NamedIntervalProfiler::getSampleFieldValueOverride ( size_t  sampleIndex,
size_t  fieldIndex 
) const
overrideprotectedvirtual

The override of AbstractProfilerRegistry::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: