Abstract value profiler. More...
#include <kanzi/core/profiling/abstract_value_profiler.hpp>
Public Types | |
typedef TProfilingDataSample | SampleDataType |
The sample data type typedef used in derived classes. More... | |
typedef TAggregateProfilingData | AggregateProfilingDataType |
The aggregate profiling data type typedef used in derived classes. 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... | |
Protected Member Functions | |
AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) | |
Constructor. More... | |
const TProfilingDataSample & | getSample (size_t index) const |
Accesses a profiling data sample stored in the sample buffer. More... | |
void | addSample (const TProfilingDataSample &sample) |
Adds a new profiling data sample. More... | |
void | addSample (KZ_RV_REF(TProfilingDataSample) sample) |
Adds a new movable profiling data sample to the profiler. More... | |
void | resetSampleData () |
Resets the aggregate profiling data and sample buffer. 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 size_t | getAggregateDataFieldCountOverride () const =0 |
To provide the number of the aggregate data fields, override this function in the derived profiler class. More... | |
virtual string | getAggregateDataFieldNameOverride (size_t fieldIndex) const =0 |
To provide the name of aggregate data field with given index, override this function in the derived profiler class. More... | |
virtual Value | getAggregateDataFieldValueOverride (size_t fieldName) const =0 |
To provide access to aggregate profiling data field values, override this function in the derived profiler class. More... | |
virtual size_t | getSampleFieldCountOverride () const =0 |
To provide the number of sample fields, override this function in the derived profiler class. More... | |
virtual string | getSampleFieldNameOverride (size_t fieldIndex) const =0 |
To provide the name of a sample field with a given index, override this function in the derived profiler class. More... | |
virtual Value | getSampleFieldValueOverride (size_t sampleIndex, size_t fieldName) const =0 |
To provide access to profiling data sample fields of the derived profiler, override this function in the derived profiler class. 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... | |
Protected Attributes | |
TAggregateProfilingData | m_aggregateProfilingData |
The aggregate profiling data. More... | |
Additional Inherited Members | |
Public Member Functions inherited from kanzi::AbstractProfiler | |
virtual | ~AbstractProfiler () |
Destructor. More... | |
string_view | getName () const |
Gets the name of the profiler. More... | |
const ProfilingCategory & | getCategory () 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 inherited from kanzi::AbstractProfiler | |
static DataType | getDataType (const Value &value) |
Gets the type of the data stored in a profiling data field. More... | |
Abstract value profiler.
Derive from AbstractValueProfiler to implement your own profiler which uses a circular buffer to store profiling samples.
The AbstractValueProfiler is a template class which stores profiling data samples of arbitrary type in a circular sample buffer. When the circular buffer runs out of space, new samples overwrite the oldest samples. The size of the sample buffer is set in constructor AbstractValueProfiler::AbstractValueProfiler().
To add a new sample to the profiler use the addSample() function in the derived class. To get a sample reference use the getSample() function in the derived class.
The AbstractValueProfiler provides a placeholder for arbitrary aggregate profiling data. You can access aggregate profiling data from the derived class through m_aggregateProfilingData.
typedef TProfilingDataSample kanzi::AbstractValueProfiler< TProfilingDataSample, TAggregateProfilingData >::SampleDataType |
The sample data type typedef used in derived classes.
typedef TAggregateProfilingData kanzi::AbstractValueProfiler< TProfilingDataSample, TAggregateProfilingData >::AggregateProfilingDataType |
The aggregate profiling data type typedef used in derived classes.
|
inlineexplicitprotected |
Constructor.
name | The name of the profiler. |
category | The profiling category assigned to the profiler. |
sampleBufferSize | The maximum size of the sample buffer. |
|
inlineprotected |
Accesses a profiling data sample stored in the sample buffer.
The sample buffer is zero-based, meaning that oldest sample is stored at index 0.
index | The index of the sample. |
|
inlineprotected |
Adds a new profiling data sample.
sample | The profiling data sample. |
|
inlineprotected |
Adds a new movable profiling data sample to the profiler.
sample | The profiling data sample. |
|
inlineprotected |
Resets the aggregate profiling data and sample buffer.
|
inlineprotectedvirtual |
Override of #AbstractProfiler::getSampleCountOverride().
Implements kanzi::AbstractProfiler.
|
protected |
The aggregate profiling data.