Kanzi 3.9.10
kanzi::MainLoopProfiler Class Reference

MainLoopProfiler implements profiling for tasks of MainLoopScheduler. More...

#include <kanzi/core.ui/main_loop/main_loop_profiler.hpp>

Inheritance diagram for kanzi::MainLoopProfiler:
[legend]

Public Types

using BaseValueProfiler
 Alias for the base class.
 
using ScopeRegistry
 Alias for the container of profiling scope tokens.
 
- Public Types inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData >
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 (MainLoopProfilingSampleData &&sample)
 Adds a profiling data sample to the profiler.
 
MainLoopProfilingScopeToken findScope (string_view name) const
 Finds a profiling scope by its name.
 
const MainLoopProfilingSampleDatagetSample (size_t index) const
 Accesses a profiling data sample stored in the sample buffer.
 
const ScopeRegistrygetScopeRegistry () const
 Returns a reference to the profiling scope registry.
 
MainLoopProfilingScopeToken registerScope (string_view name)
 Registers a profiling scope.
 
void resetSampleBufferSize (size_t sampleBufferSize)
 Resets the size of the sample buffer of the profiler.
 
void resetSampleData ()
 Clears the sample buffer and resets the sample statistics.
 
- Public Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData >
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 ProfilingCategorygetCategory () 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 MainLoopProfilerSharedPtr create (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Creates a main loop task profiler.
 
static const chargetScopeName (MainLoopProfilingScopeToken token)
 Returns the name of a profiling scope given its token.
 
- 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

MainLoopProfilingScopeTokenfindFirstObsoleteScope ()
 Returns first obsolete entry in the scope registry.
 
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 AbstractProfiler::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 AbstractProfiler::getSampleFieldValueOverride().
 
 MainLoopProfiler (const MainLoopProfiler &rhs)=delete
 
 MainLoopProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor.
 
MainLoopProfileroperator= (const MainLoopProfiler &rhs)=delete
 
void sortScopeRegistry ()
 Sorts the scope registry entries in the lexicographical order of their names.
 
- Protected Member Functions inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData >
 AbstractValueProfiler (string_view name, const ProfilingCategory &category, size_t sampleBufferSize)
 Constructor.
 
void addSample (const MainLoopProfilingSampleData &sample)
 Adds a new profiling data sample.
 
void addSample (MainLoopProfilingSampleData &&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 MainLoopProfilingSampleDatagetSample (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.
 

Protected Attributes

ScopeRegistry m_scopeRegistry
 A container of scopes registered with the profiler.
 
- Protected Attributes inherited from kanzi::AbstractValueProfiler< MainLoopProfilingSampleData, MainLoopProfilingAggregateData >
MainLoopProfilingAggregateData m_aggregateProfilingData
 The aggregate profiling data.
 
FullBufferCallbackContainer m_fullBufferCallbacks
 The container of buffer full callbacks.
 
circular_buffer< MainLoopProfilingSampleDatam_sampleBuffer
 The profiling data sample buffer.
 

Additional Inherited Members

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

Detailed Description

MainLoopProfiler implements profiling for tasks of MainLoopScheduler.

Member Typedef Documentation

◆ BaseValueProfiler

◆ ScopeRegistry

Alias for the container of profiling scope tokens.

Constructor & Destructor Documentation

◆ MainLoopProfiler() [1/2]

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

◆ MainLoopProfiler() [2/2]

kanzi::MainLoopProfiler::MainLoopProfiler ( const MainLoopProfiler & rhs)
protecteddelete

Member Function Documentation

◆ create()

static MainLoopProfilerSharedPtr kanzi::MainLoopProfiler::create ( string_view name,
const ProfilingCategory & category,
size_t sampleBufferSize )
static

Creates a main loop task profiler.

Parameters
nameThe name of the profiler.
categoryThe category assigned to the profiler.
sampleBufferSizeThe maximum size of the sample buffer.
Returns
A unique pointer to the new profiler.

◆ resetSampleBufferSize()

void kanzi::MainLoopProfiler::resetSampleBufferSize ( size_t sampleBufferSize)

Resets the size of the sample buffer of the profiler.

Parameters
sampleBufferSizeThe maximum size of the sample buffer.

◆ addSample()

void kanzi::MainLoopProfiler::addSample ( MainLoopProfilingSampleData && sample)

Adds a profiling data sample to the profiler.

Parameters
sampleThe profiling data sample.

◆ resetSampleData()

void kanzi::MainLoopProfiler::resetSampleData ( )

Clears the sample buffer and resets the sample statistics.

◆ getSample()

const MainLoopProfilingSampleData & kanzi::MainLoopProfiler::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.

◆ registerScope()

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.

Parameters
nameThe name of the profiling scope.
Returns
A token for the profiling scope.

◆ findScope()

MainLoopProfilingScopeToken kanzi::MainLoopProfiler::findScope ( string_view name) const

Finds a profiling scope by its name.

Returns the scope token.

Parameters
nameThe name of the profiling scope.
Returns
The token for the found profiling scope. If no scope with the matching name is found, a default constructed token is returned.

◆ getScopeRegistry()

const ScopeRegistry & kanzi::MainLoopProfiler::getScopeRegistry ( ) const
inline

Returns a reference to the profiling scope registry.

Returns
Reference to the profiling scope registry.

◆ getScopeName()

static const char * kanzi::MainLoopProfiler::getScopeName ( MainLoopProfilingScopeToken token)
static

Returns the name of a profiling scope given its token.

Parameters
tokenToken of the profiling scope.
Returns
Name of the profiling scope.

◆ operator=()

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

◆ getAggregateDataFieldCountOverride()

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

The override of AbstractProfiler::getAggregateDataFieldCountOverride().

Returns
The number of aggregate data fields.

Implements kanzi::AbstractProfiler.

◆ getAggregateDataFieldNameOverride()

string kanzi::MainLoopProfiler::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::MainLoopProfiler::getSampleFieldCountOverride ( ) const
overrideprotectedvirtual

The override of AbstractProfiler::getSampleFieldCountOverride().

Returns
The number of sample data fields.

Implements kanzi::AbstractProfiler.

◆ getSampleFieldNameOverride()

string kanzi::MainLoopProfiler::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::MainLoopProfiler::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::MainLoopProfiler::getAggregateDataFieldValueOverride ( size_t fieldIndex) const
overrideprotectedvirtual

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.

◆ getSampleFieldValueOverride()

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

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.

◆ sortScopeRegistry()

void kanzi::MainLoopProfiler::sortScopeRegistry ( )
protected

Sorts the scope registry entries in the lexicographical order of their names.

◆ findFirstObsoleteScope()

MainLoopProfilingScopeToken * kanzi::MainLoopProfiler::findFirstObsoleteScope ( )
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.

Returns
Pointer to a obsolete entry in the scope registry if found, otherwise nullptr.

Member Data Documentation

◆ m_scopeRegistry

ScopeRegistry kanzi::MainLoopProfiler::m_scopeRegistry
protected

A container of scopes registered with the profiler.


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