The resource profiling context. More...
#include <kanzi/core.ui/resource/resource_profiling_context.hpp>
Public Types | |
typedef chrono::nanoseconds | Duration |
The duration type. More... | |
typedef chrono::high_resolution_clock::time_point | TimePoint |
The timepoint type. More... | |
typedef Duration | TimeStamp |
The timestamp. More... | |
typedef vector< ResourceProfilingContextSharedPtr > | ResourceProfilingContextContainer |
The resource profiling context container. More... | |
Public Member Functions | |
virtual | ~ResourceProfilingContext () |
Destructor. More... | |
void | addDependencyContext (ResourceProfilingContextSharedPtr context) |
Adds a dependency context. More... | |
void | getAttributes (ResourceProfilingAttributes &attributes) const |
Retrieves the attributes of the context. More... | |
const ResourceProfilingContextContainer & | getDependencyContexts () const |
Gets dependency contexts container. More... | |
uint64_t | getID () const |
Gets the unique identifier of the context. More... | |
TimeStamp | getEntryTimeStamp () const |
Gets the entry timestamp of the context. More... | |
Static Public Member Functions | |
static TimeStamp | getCurrentTimeStamp () |
Gets the current timestamp. More... | |
static TimePoint | getCurrentTimePoint () |
Gets the current timepoint. More... | |
Protected Member Functions | |
ResourceProfilingContext (TimeStamp entryTimeStamp) | |
Constructor. More... | |
Duration | getDependenciesDuration () const |
Gets the total duration of all dependency contexts. More... | |
virtual void | getAttributesOverride (ResourceProfilingAttributes &attributes) const |
Gets the attributes of the context defined in the derived class. More... | |
virtual Duration | getDurationOverride () const |
Gets the duration of the context. More... | |
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.
typedef chrono::high_resolution_clock::time_point kanzi::ResourceProfilingContext::TimePoint |
The timepoint 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. |
|
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.
|
static |
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.
|
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::ResourceProfilingAcquireContext, kanzi::GenericResourceProfilingContext, kanzi::NamedResourceProfilingContext, 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.