MainLoopProfiler implements profiling for tasks of MainLoopScheduler. More...
#include <kanzi/core.ui/main_loop/main_loop_profiler.hpp>
Public Types | |
using | BaseValueProfiler = AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > |
Alias for the base class. More... | |
using | ScopeRegistry = vector< MainLoopProfilingScopeToken > |
Alias for the container of profiling scope tokens. More... | |
Public Types inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
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 (MainLoopProfilingSampleData &&sample) |
Adds a profiling data sample to the profiler. More... | |
MainLoopProfilingScopeToken | findScope (string_view name) const |
Finds a profiling scope by its name. More... | |
const MainLoopProfilingSampleData & | getSample (size_t index) const |
Accesses a profiling data sample stored in the sample buffer. More... | |
const ScopeRegistry & | getScopeRegistry () const |
Returns a reference to the profiling scope registry. More... | |
MainLoopProfilingScopeToken | registerScope (string_view name) |
Registers a profiling scope. More... | |
void | resetSampleBufferSize (size_t sampleBufferSize) |
Resets the size of the sample buffer of the profiler. More... | |
void | resetSampleData () |
Clears the sample buffer and resets the sample statistics. More... | |
Public Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
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 ProfilingCategory & | getCategory () 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 MainLoopProfilerSharedPtr | create (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) |
Creates a main loop task profiler. More... | |
static const char * | getScopeName (MainLoopProfilingScopeToken token) |
Returns the name of a profiling scope given its token. 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 | |
MainLoopProfilingScopeToken * | findFirstObsoleteScope () |
Returns first obsolete entry in the scope registry. More... | |
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 AbstractProfiler::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 AbstractProfiler::getSampleFieldValueOverride(). More... | |
MainLoopProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) | |
Constructor. More... | |
MainLoopProfiler (const MainLoopProfiler &rhs)=delete | |
MainLoopProfiler & | operator= (const MainLoopProfiler &rhs)=delete |
void | sortScopeRegistry () |
Sorts the scope registry entries in the lexicographical order of their names. More... | |
Protected Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize) | |
Constructor. More... | |
void | addSample (const MainLoopProfilingSampleData &sample) |
Adds a new profiling data sample. More... | |
void | addSample (MainLoopProfilingSampleData &&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 MainLoopProfilingSampleData & | getSample (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... | |
Protected Attributes | |
ScopeRegistry | m_scopeRegistry |
A container of scopes registered with the profiler. More... | |
Protected Attributes inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
MainLoopProfilingAggregateData | m_aggregateProfilingData |
The aggregate profiling data. More... | |
FullBufferCallbackContainer | m_fullBufferCallbacks |
The container of buffer full callbacks. More... | |
circular_buffer< MainLoopProfilingSampleData > | m_sampleBuffer |
The profiling data sample buffer. More... | |
Additional Inherited Members | |
Protected Types inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
typedef MainLoopProfilingAggregateData | AggregateProfilingDataType |
The aggregate profiling data type typedef used in derived classes. More... | |
typedef vector< FullBufferCallbackSharedPtr > | FullBufferCallbackContainer |
The typedef used for container of full buffer callback shared pointers. More... | |
typedef shared_ptr< FullBufferCallback > | FullBufferCallbackSharedPtr |
The typedef used for shared pointer to full buffer callback. More... | |
typedef MainLoopProfilingSampleData | SampleDataType |
The sample data type typedef used in derived classes. More... | |
Static Protected Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData > | |
static void | invokeBufferFullCallback (AbstractValueProfiler &profiler, FullBufferCallbackSharedPtr &callback) |
Internal helper function used by checkBufferFull. More... | |
MainLoopProfiler implements profiling for tasks of MainLoopScheduler.
using kanzi::MainLoopProfiler::BaseValueProfiler = AbstractValueProfiler<MainLoopProfilingSampleData, MainLoopProfilingAggregateData> |
Alias for the base class.
using kanzi::MainLoopProfiler::ScopeRegistry = vector<MainLoopProfilingScopeToken> |
Alias for the container of profiling scope tokens.
|
explicitprotected |
Constructor.
name | The name of the profiler. |
category | The category assigned to the profiler. |
sampleBufferSize | The maximum size of the sample buffer. |
|
protecteddelete |
|
static |
Creates a main loop task profiler.
name | The name of the profiler. |
category | The category assigned to the profiler. |
sampleBufferSize | The maximum size of the sample buffer. |
void kanzi::MainLoopProfiler::resetSampleBufferSize | ( | size_t | sampleBufferSize | ) |
Resets the size of the sample buffer of the profiler.
sampleBufferSize | The maximum size of the sample buffer. |
void kanzi::MainLoopProfiler::addSample | ( | MainLoopProfilingSampleData && | sample | ) |
Adds a profiling data sample to the profiler.
sample | The profiling data sample. |
void kanzi::MainLoopProfiler::resetSampleData | ( | ) |
Clears the sample buffer and resets the sample statistics.
|
inline |
Accesses a profiling data sample stored in the sample buffer.
index | The index of the sample. |
MainLoopProfilingScopeToken kanzi::MainLoopProfiler::registerScope | ( | string_view | name | ) |
Registers a profiling scope.
Returns the scope token. Pass this as an argument to the sampler constructor when profiling the respective scope.
name | The name of the profiling scope. |
MainLoopProfilingScopeToken kanzi::MainLoopProfiler::findScope | ( | string_view | name | ) | const |
Finds a profiling scope by its name.
Returns the scope token.
name | The name of the profiling scope. |
|
inline |
Returns a reference to the profiling scope registry.
|
static |
Returns the name of a profiling scope given its token.
token | Token of the profiling scope. |
|
protecteddelete |
|
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 AbstractProfiler::getAggregateDataFieldValueOverride().
fieldIndex | The index of the aggregate profiling data field. |
Implements kanzi::AbstractProfiler.
|
overrideprotectedvirtual |
The override of AbstractProfiler::getSampleFieldValueOverride().
sampleIndex | The index of the profiling data sample. |
fieldIndex | The index of the profiling data sample field. |
Implements kanzi::AbstractProfiler.
|
protected |
Sorts the scope registry entries in the lexicographical order of their names.
|
protected |
Returns first obsolete entry in the scope registry.
A obsolete scope is one which is older than the oldest sample in sample buffer, and has no external references to it.
|
protected |
A container of scopes registered with the profiler.