The resource profiling context. More...
#include <kanzi/core.ui/resource/resource_profiling_context.hpp>
Public Types | |
typedef chrono::nanoseconds | Duration |
The duration type. | |
typedef vector< ResourceProfilingContextSharedPtr > | ResourceProfilingContextContainer |
The resource profiling context container. | |
typedef Duration | TimeStamp |
The timestamp. | |
Public Member Functions | |
void | addDependencyContext (ResourceProfilingContextSharedPtr context) |
Adds a dependency context. | |
void | getAttributes (ResourceProfilingAttributes &attributes) const |
Retrieves the attributes of the context. | |
const ResourceProfilingContextContainer & | getDependencyContexts () const |
Gets dependency contexts container. | |
TimeStamp | getEntryTimeStamp () const |
Gets the entry timestamp of the context. | |
uint64_t | getID () const |
Gets the unique identifier of the context. | |
void | recordExitTimeStamp () |
Records exit timestamp on the context. | |
virtual | ~ResourceProfilingContext () |
Destructor. | |
Static Public Member Functions | |
static TimePoint | getCurrentTimePoint () |
Gets the current timepoint. | |
static TimeStamp | getCurrentTimeStamp () |
Gets the current timestamp. | |
Protected Member Functions | |
virtual void | getAttributesOverride (ResourceProfilingAttributes &attributes) const |
Gets the attributes of the context defined in the derived class. | |
Duration | getDependenciesDuration () const |
Gets the total duration of all dependency contexts. | |
virtual Duration | getDurationOverride () const |
Gets the duration of the context. | |
ResourceProfilingContext (TimeStamp entryTimeStamp) | |
Constructor. | |
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.
typedef chrono::nanoseconds kanzi::ResourceProfilingContext::Duration |
The duration type.
The timestamp.
typedef vector<ResourceProfilingContextSharedPtr> kanzi::ResourceProfilingContext::ResourceProfilingContextContainer |
The resource profiling context container.
|
virtual |
Destructor.
|
inlineexplicitprotected |
Constructor.
entryTimeStamp | The resource profiling context entry timestamp. |
void kanzi::ResourceProfilingContext::addDependencyContext | ( | ResourceProfilingContextSharedPtr | context | ) |
Adds a dependency context.
To get all dependency contexts use the getDependencyContexts() function.
context | The dependency context. |
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.
attributes | The attributes object to fill out with the attributes of the context. |
Gets the current timestamp.
Every invocation of this function returns a timestamp greater than or equal to the values previously returned by this function.
Gets the current timepoint.
The timepoint is returned by high-resolution timer.
|
inline |
Gets dependency contexts container.
uint64_t kanzi::ResourceProfilingContext::getID | ( | ) | const |
Gets the unique identifier of the context.
Use the identifier to tell apart contexts of the same type.
|
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.
void kanzi::ResourceProfilingContext::recordExitTimeStamp | ( | ) |
Records exit timestamp on the context.
|
inlineprotected |
Gets the total duration of all dependency contexts.
|
protectedvirtual |
Gets the attributes of the context defined in the derived class.
attributes | The attributes object to fill out with the attributes of the context. |
Reimplemented in kanzi::GenericResourceProfilingContext, kanzi::NamedResourceProfilingContext, kanzi::ResourceProfilingAcquireContext, kanzi::ResourceProfilingDeployContext, kanzi::ResourceProfilingLoadContext, and kanzi::ResourceProfilingMainLoopContext.
|
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.
Reimplemented in kanzi::ResourceProfilingDeployContext, and kanzi::ResourceProfilingLoadContext.