The interval profiler. More...
#include <kanzi/core/profiling/interval_profiler.hpp>
Public Types | |
typedef AbstractValueProfiler< IntervalProfilerSampleData, IntervalProfilerSampleStatistics > | BaseValueProfiler |
The typedef of the base value profiler class. | |
Public Types inherited from kanzi::AbstractValueProfiler< IntervalProfilerSampleData, IntervalProfilerSampleStatistics > | |
typedef function< void(AbstractValueProfiler &) | FullBufferCallback) |
The typedef used for full buffer callback. | |
typedef weak_ptr< void > | FullBufferCallbackHandle |
The typedef used for full buffer callback handle. | |
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. | |
Public Member Functions | |
void | addSample (const IntervalProfilerSampleData &sample) |
Adds a new profiling data sample to the profiler. | |
const IntervalProfilerSampleStatistics & | getProfilingStatistics () const |
Gets a reference to interval profiling statistics. | |
const IntervalProfilerSampleData & | getSample (size_t index) const |
Accesses a profiling data sample stored in the sample buffer. | |
Public Member Functions inherited from kanzi::AbstractValueProfiler< IntervalProfilerSampleData, IntervalProfilerSampleStatistics > | |
FullBufferCallbackHandle | addFullBufferCallback (FullBufferCallback callback) |
Adds a new full buffer callback. | |
void | removeFullBufferCallback (const FullBufferCallbackHandle &callbackHandle) |
Removes a full buffer callback. | |
void | resetSampleData () |
Resets the aggregate profiling data and sample buffer. | |
Public Member Functions inherited from kanzi::AbstractProfiler | |
size_t | getAggregateDataFieldCount () const |
Gets the number of aggregate data fields. | |
string | getAggregateDataFieldName (size_t fieldIndex) const |
Gets the name of an aggregate data field. | |
Value | getAggregateDataFieldValue (size_t fieldIndex) const |
Gets the value of an aggregate profiling data field. | |
const ProfilingCategory & | getCategory () const |
Gets a reference to the profiling category assigned to the profiler. | |
string_view | getName () const |
Gets the name of the profiler. | |
size_t | getSampleCount () const |
Gets the number of collected profiling data samples. | |
size_t | getSampleFieldCount () const |
Gets the number of sample data fields. | |
DataType | getSampleFieldDataType (size_t fieldIndex) const |
Gets the data type of a data sample field. | |
string | getSampleFieldName (size_t fieldIndex) const |
Gets the name of a data sample field. | |
Value | getSampleFieldValue (size_t sampleIndex, size_t fieldIndex) const |
Gets the value of a profiling data sample field. | |
void | logAggregateData () const |
Logs aggregate profiling data. | |
void | logAllData () const |
Logs all profiling data. | |
virtual | ~AbstractProfiler () |
Destructor. | |
Static Public Member Functions | |
static IntervalProfilerSharedPtr | create (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) |
Creates a new interval profiler. | |
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. | |
Protected Member Functions | |
size_t | getAggregateDataFieldCountOverride () const override |
The override of AbstractProfiler::getAggregateDataFieldCountOverride(). | |
string | getAggregateDataFieldNameOverride (size_t fieldIndex) const override |
The override of AbstractProfiler::getAggregateDataFieldNameOverride(). | |
Value | getAggregateDataFieldValueOverride (size_t fieldIndex) const override |
The override of AbstractProfilerRegistry::getAggregateDataFieldValueOverride(). | |
size_t | getSampleFieldCountOverride () const override |
The override of AbstractProfiler::getSampleFieldCountOverride(). | |
DataType | getSampleFieldDataTypeOverride (size_t fieldIndex) const override |
The override of AbstractProfiler::getSampleFieldDataTypeOverride(). | |
string | getSampleFieldNameOverride (size_t fieldIndex) const override |
The override of AbstractProfiler::getSampleFieldNameOverride(). | |
Value | getSampleFieldValueOverride (size_t sampleIndex, size_t fieldIndex) const override |
The override of AbstractProfilerRegistry::getSampleFieldValueOverride(). | |
IntervalProfiler (const IntervalProfiler &rhs) KZ_DELETED_FUNCTION | |
Deleted copy constructor, preventing copying of the object. | |
IntervalProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) | |
Constructor. | |
IntervalProfiler & | operator= (const IntervalProfiler &rhs) KZ_DELETED_FUNCTION |
Deleted assignment operator, preventing assignment of the object. | |
Protected Member Functions inherited from kanzi::AbstractValueProfiler< IntervalProfilerSampleData, IntervalProfilerSampleStatistics > | |
AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) | |
Constructor. | |
void | addSample (const IntervalProfilerSampleData &sample) |
Adds a new profiling data sample. | |
void | addSample (IntervalProfilerSampleData &&sample) |
Adds a new movable profiling data sample to the profiler. | |
void | checkBufferFull () |
Performs all buffer full callbacks and clears samples if buffer is full. | |
const IntervalProfilerSampleData & | getSample (size_t index) const |
Accesses a profiling data sample stored in the sample buffer. | |
size_t | getSampleCountOverride () const override |
Override of AbstractProfiler::getSampleCountOverride(). | |
void | resetSampleBufferSize (size_t sampleBufferSize) |
Resets the size of the sample buffer. | |
Protected Member Functions inherited from kanzi::AbstractProfiler | |
AbstractProfiler (string_view name, const ProfilingCategory &category) | |
Constructor. | |
virtual void | logAggregateDataOverride () const |
To implement your own logging of aggregate profiling data, override this function in the derived profiler class. | |
virtual void | logAllDataOverride () const |
To implement your own logging of all profiling data, override this function in the derived profiler class. | |
The interval profiler.
Use Profiling macros to profile codepath execution time.
The interval profiler collects samples of IntervalProfilerSampleData type which include information about interval duration and start point. For details on the information included in the sample, see IntervalProfilerSampleData. For an example of how interval profiling sample is collected in scope profiling, see IntervalProfilerSampler.
To add the collected sample to the profiler, use the addSample() function.
The IntervalProfiler 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().
typedef AbstractValueProfiler<IntervalProfilerSampleData, IntervalProfilerSampleStatistics> kanzi::IntervalProfiler::BaseValueProfiler |
The typedef of the base value profiler class.
|
explicitprotected |
Constructor.
name | The name of the profiler. |
category | The category assigned to the profiler. |
sampleBufferSize | The maximum size of the sample buffer. |
|
protected |
Deleted copy constructor, preventing copying of the object.
|
static |
Creates a new interval profiler.
name | The name of the new profiler. |
category | The profiling category assigned to the profiler. |
sampleBufferSize | The maximum size of the profiling sample buffer. |
void kanzi::IntervalProfiler::addSample | ( | const IntervalProfilerSampleData & | sample | ) |
Adds a new profiling data sample to the profiler.
sample | The profiling data sample. |
|
inline |
Accesses a profiling data sample stored in the sample buffer.
index | The index of the sample. |
|
inline |
Gets a reference to interval profiling statistics.
|
protected |
Deleted assignment operator, preventing assignment of the object.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getAggregateDataFieldCountOverride().
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getAggregateDataFieldNameOverride().
fieldIndex | The index of the field. |
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getSampleFieldCountOverride().
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getSampleFieldNameOverride().
fieldIndex | The index of the sample field. |
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getSampleFieldDataTypeOverride().
fieldIndex | The index of the field. |
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfilerRegistry::getAggregateDataFieldValueOverride().
fieldIndex | The index of the aggregate profiling data field. |
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfilerRegistry::getSampleFieldValueOverride().
sampleIndex | The index of the profiling data sample. |
fieldIndex | The index of the profiling data sample field. |
Implements kanzi::AbstractProfiler.