Kanzi  3.9.6
Kanzi Engine API
kanzi::ProfilingScopeHelper Class Reference

The profiling scope helper. More...

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

Public Types

typedef void(* CollectSampleFunctionType) (void *, void *)
 The pointer to the template function instantiation for profiler and sampler types passed to the ProfilingScopeHelper::ProfilingScopeHelper(). More...
 

Public Member Functions

template<typename TProfiler , typename TProfilingSampler >
 ProfilingScopeHelper (const shared_ptr< TProfiler > &profiler, TProfilingSampler &sampler)
 Constructor. More...
 
 ~ProfilingScopeHelper ()
 Destructor. More...
 

Detailed Description

The profiling scope helper.

Do not use this class directly. It is used internally by Profiling macros.

The ProfilingScopeHelper is used in scope profiling. The profiling macros (Profiling macros) create a local variable of ProfilingScopeHelper to profile the execution time of the enclosing scope. For example, see kzProfileScope().

Since the profiling helper variable is local to the profiled scope, ProfilingScopeHelper::ProfilingScopeHelper() constructor is called every time the scope is entered. The destructor ProfilingScopeHelper::~ProfilingScopeHelper() is called just before scope is left.

The sample data object passed to constructor ProfilingScopeHelper::ProfilingScopeHelper() collects sample data. The ProfilingScopeHelper calls sampler object methods to start and stop profiling, to collect sample data, and to pass the data to the profiler.

The constructor ProfilingScopeHelper::ProfilingScopeHelper() starts profiling the scope by calling the start() method of the sampler object. The destructor ProfilingScopeHelper::~ProfilingScopeHelper() stops profiling the scope by calling the stop() method of the sampler object. To get sample data the destructor ProfilingScopeHelper::~ProfilingScopeHelper() calls the getSampleData() method of the sampler object and adds that data to the profiler.

Member Typedef Documentation

◆ CollectSampleFunctionType

typedef void(* kanzi::ProfilingScopeHelper::CollectSampleFunctionType) (void *, void *)

The pointer to the template function instantiation for profiler and sampler types passed to the ProfilingScopeHelper::ProfilingScopeHelper().

Constructor & Destructor Documentation

◆ ProfilingScopeHelper()

template<typename TProfiler , typename TProfilingSampler >
kanzi::ProfilingScopeHelper::ProfilingScopeHelper ( const shared_ptr< TProfiler > &  profiler,
TProfilingSampler &  sampler 
)
inlineexplicit

Constructor.

This constructor is called on entry to the scope, where local variable of ProfilingScopeHelper is defined. The constructor initializes m_collectFunction with pointer to collectSample() instantiated with the profiler and sampler types. This function is used later in destructor on scope exit. The pointers to sampler and profiler are stored in m_sampler and m_profiler to pass these values to the m_collectFunction in the destructor.

If the profiling category assigned to the profiler is disabled then this constructor does nothing and stores 0 pointer in m_collectFunction.

Parameters
profilerThe profiler shared pointer to add samples to.
samplerThe sampler to collect sample data.

◆ ~ProfilingScopeHelper()

kanzi::ProfilingScopeHelper::~ProfilingScopeHelper ( )
inline

Destructor.

This destructor is called on the exit from the scope, where local variable of ProfilingScopeHelper is defined. The destructor calls m_collectFunction with m_profiler and m_sampler to collect sample and add it to the profiler.

If the m_collectFunction is 0, this destructor does not do anything.


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