Kanzi  3.9.5
Kanzi Engine API
kanzi::ResourceProfilingContext Class Reference

The resource profiling context. More...

#include <kanzi/core.ui/resource/resource_profiling_context.hpp>

Inheritance diagram for kanzi::ResourceProfilingContext:
[legend]

Public Types

typedef chrono::nanoseconds Duration
 The duration type. More...
 
typedef vector< ResourceProfilingContextSharedPtrResourceProfilingContextContainer
 The resource profiling context container. More...
 
typedef Duration TimeStamp
 The timestamp. More...
 

Public Member Functions

void addDependencyContext (ResourceProfilingContextSharedPtr context)
 Adds a dependency context. More...
 
void getAttributes (ResourceProfilingAttributes &attributes) const
 Retrieves the attributes of the context. More...
 
const ResourceProfilingContextContainergetDependencyContexts () const
 Gets dependency contexts container. More...
 
TimeStamp getEntryTimeStamp () const
 Gets the entry timestamp of the context. More...
 
uint64_t getID () const
 Gets the unique identifier of the context. More...
 
void recordExitTimeStamp ()
 Records exit timestamp on the context. More...
 
virtual ~ResourceProfilingContext ()
 Destructor. More...
 

Static Public Member Functions

static TimePoint getCurrentTimePoint ()
 Gets the current timepoint. More...
 
static TimeStamp getCurrentTimeStamp ()
 Gets the current timestamp. More...
 

Protected Member Functions

virtual void getAttributesOverride (ResourceProfilingAttributes &attributes) const
 Gets the attributes of the context defined in the derived class. More...
 
Duration getDependenciesDuration () const
 Gets the total duration of all dependency contexts. More...
 
virtual Duration getDurationOverride () const
 Gets the duration of the context. More...
 
 ResourceProfilingContext (TimeStamp entryTimeStamp)
 Constructor. More...
 

Detailed Description

The resource profiling context.

The resource profiling context represents a scope that executes code path which at some point triggers resource loading or deployment. Only resource profiling context samplers create resource profiling contexts. A sampler creates a context only when the execution of the scope where the sampler is defined triggers resource loading or deployment. For example, when the ResourceManager::acquireResource() function is called for a resource that is already loaded and deployed, the sampler does not create a context.

To create a resource profiling context sampler call the kzResourceProfilingContextSampler() macro in the scope where you want to create the sampler. See ResourceProfilingContextFactory::AbstractSampler.

The scope where you define the resource profiling context sampler may execute code path that triggers the execution of another scope for which you also defined a resource profiling sampler context. For example, scope A for which you defined the sampler samplerA executes code path which triggers the execution of scope B for which you defined the sampler samplerB. If the code path in scope B triggers resource loading or deployment, SamplerB creates a resource profiling context which is a dependency context for the context created by SamplerA. To get all dependency contexts for a specific resource profiling context use the getDependencyContexts() function.

The duration of a resource profiling context is equal to the duration of the resource loading or deployment triggered by the execution of the corresponding scope. Scope execution may trigger the loading or deployment of multiple resources.

In scopes where resources are loaded and deployed Kanzi creates samplers for the corresponding loading and deployment contexts kanzi::ResourceProfilingLoadContext and kanzi::ResourceProfilingDeployContext.

Member Typedef Documentation

◆ Duration

typedef chrono::nanoseconds kanzi::ResourceProfilingContext::Duration

The duration type.

◆ TimeStamp

◆ ResourceProfilingContextContainer

Constructor & Destructor Documentation

◆ ~ResourceProfilingContext()

virtual kanzi::ResourceProfilingContext::~ResourceProfilingContext ( )
virtual

Destructor.

◆ ResourceProfilingContext()

kanzi::ResourceProfilingContext::ResourceProfilingContext ( TimeStamp  entryTimeStamp)
inlineexplicitprotected

Constructor.

Parameters
entryTimeStampThe resource profiling context entry timestamp.
See also
getEntryTimeStamp()

Member Function Documentation

◆ addDependencyContext()

void kanzi::ResourceProfilingContext::addDependencyContext ( ResourceProfilingContextSharedPtr  context)

Adds a dependency context.

To get all dependency contexts use the getDependencyContexts() function.

Parameters
contextThe dependency context.
See also
getDependencyContexts()

◆ getAttributes()

void kanzi::ResourceProfilingContext::getAttributes ( ResourceProfilingAttributes attributes) const

Retrieves the attributes of the context.

The attributes object you pass with the attributes parameter is filled out with attributes of this context.

Parameters
attributesThe attributes object to fill out with the attributes of the context.

◆ getCurrentTimeStamp()

static TimeStamp kanzi::ResourceProfilingContext::getCurrentTimeStamp ( )
static

Gets the current timestamp.

Every invocation of this function returns a timestamp greater than or equal to the values previously returned by this function.

Returns
The current timestamp.

◆ getCurrentTimePoint()

static TimePoint kanzi::ResourceProfilingContext::getCurrentTimePoint ( )
static

Gets the current timepoint.

The timepoint is returned by high-resolution timer.

Returns
The current timepoint.

◆ getDependencyContexts()

const ResourceProfilingContextContainer& kanzi::ResourceProfilingContext::getDependencyContexts ( ) const
inline

Gets dependency contexts container.

Returns
The container of the dependency contexts.

◆ getID()

uint64_t kanzi::ResourceProfilingContext::getID ( ) const

Gets the unique identifier of the context.

Use the identifier to tell apart contexts of the same type.

Returns
The unique identifier of the context.

◆ getEntryTimeStamp()

TimeStamp kanzi::ResourceProfilingContext::getEntryTimeStamp ( ) const
inline

Gets the entry timestamp of the context.

The timestamp is calculated at entry to the scope where the context is created. The value is deduced from incrementing high-resolution timer. If context A is created before context B, the timestamp of A is less than or equal to the timestamp of B.

Returns
The measurement timestamp.

◆ recordExitTimeStamp()

void kanzi::ResourceProfilingContext::recordExitTimeStamp ( )

Records exit timestamp on the context.

◆ getDependenciesDuration()

Duration kanzi::ResourceProfilingContext::getDependenciesDuration ( ) const
inlineprotected

Gets the total duration of all dependency contexts.

Returns
The total duration of all dependency contexts.

◆ getAttributesOverride()

virtual void kanzi::ResourceProfilingContext::getAttributesOverride ( ResourceProfilingAttributes attributes) const
protectedvirtual

Gets the attributes of the context defined in the derived class.

Parameters
attributesThe attributes object to fill out with the attributes of the context.
See also
getAttributes()

Reimplemented in kanzi::ResourceProfilingAcquireContext, kanzi::GenericResourceProfilingContext, kanzi::NamedResourceProfilingContext, kanzi::ResourceProfilingDeployContext, kanzi::ResourceProfilingLoadContext, and kanzi::ResourceProfilingMainLoopContext.

◆ getDurationOverride()

virtual Duration kanzi::ResourceProfilingContext::getDurationOverride ( ) const
inlineprotectedvirtual

Gets the duration of the context.

The duration of the context is the sum of the duration of resource loading and deployment that occurred in the scope of this context and the dependency contexts.

Returns
The duration of the context.

Reimplemented in kanzi::ResourceProfilingDeployContext, and kanzi::ResourceProfilingLoadContext.


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