Kanzi Framework  3.9.0
Kanzi Engine API
Resource profiling

Use the resource profiling subsystem to measure during runtime how long it takes to load and deploy resources. More...

Collaboration diagram for Resource profiling:

Classes

class  kanzi::GenericResourceProfilingContext
 Generic resource profiling context. More...
 
class  kanzi::NamedResourceProfilingContext
 Named resource profiling context. More...
 
class  kanzi::ResourceProfiler
 The resource profiler. More...
 
class  kanzi::ResourceProfilingAcquireContext
 The profiling context of resource acquirement. More...
 
class  kanzi::ResourceProfilingAttributes
 Container for resource profiling attributes. More...
 
class  kanzi::ResourceProfilingContext
 The resource profiling context. More...
 
class  kanzi::ResourceProfilingContextFactory
 Resource profiling context factory. More...
 
class  kanzi::ResourceProfilingDataSample
 The resource profiling data sample. More...
 
class  kanzi::ResourceProfilingDeployContext
 The profiling context of resource deployment. More...
 
class  kanzi::ResourceProfilingLoadContext
 The profiling context of resource loading. More...
 
class  kanzi::ResourceProfilingLoadTask
 Resource profiling wrapper for load task. More...
 
class  kanzi::ResourceProfilingMainLoopContext
 The main loop resource profiling context. More...
 
struct  kanzi::ResourceProfilingPtreePopulator
 Resource profiling ptree populator. More...
 

Macros

#define KZ_PROFILING_DEFAULT_RESOURCE_LOADING_CATEGORY_STATE
 
#define KZ_PROFILING_RESOURCE_LOADING_CATEGORY
 Kanzi uses this category to profile resource loading. More...
 
#define kzResourceProfilingContextSampler(className, localVariable, constructorArguments)
 Creates a new resource profiling context sampler. More...
 

Detailed Description

Use the resource profiling subsystem to measure during runtime how long it takes to load and deploy resources.

Resource profiling is available only in the Kanzi profiling build.

Macro Definition Documentation

◆ KZ_PROFILING_DEFAULT_RESOURCE_LOADING_CATEGORY_STATE

#define KZ_PROFILING_DEFAULT_RESOURCE_LOADING_CATEGORY_STATE

◆ KZ_PROFILING_RESOURCE_LOADING_CATEGORY

#define KZ_PROFILING_RESOURCE_LOADING_CATEGORY

Kanzi uses this category to profile resource loading.

The compile-time state of this category is defined by KZ_PROFILING_DEFAULT_RESOURCE_LOADING_CATEGORY_STATE.

◆ kzResourceProfilingContextSampler

#define kzResourceProfilingContextSampler (   className,
  localVariable,
  constructorArguments 
)

Creates a new resource profiling context sampler.

Call this macro in the scope in which you want to create a new resource profiling context sampler. This macro produces no code if KZ_PROFILING_RESOURCE_LOADING_CATEGORY profiling category is disabled at compile-time.

Parameters
classNameThe class name of the context sampler.
localVariableThe name of the local variable which holds the object of the sampler class.
constructorArgumentsThe arguments which you must pass to the constructor of the sampler. Enclose the arguments in parentheses.
See also
kanzi::ResourceProfilingContext, kanzi::ResourceProfilingContextFactory

Example

To create resource profiling samplers.

#include <kanzi/kanzi.hpp>
using namespace kanzi;
class ResourceProfilingExample : public Application
{
protected:
void loadTexture()
{
// Texture name.
string textureUrl("kzb://myproject/Textures/Texture1");
// The sampler created by this macro creates the "loadTexture" context only if the texture being acquired is not yet loaded or deployed.
// The created context will be a dependency for the "onProjectLoaded" context created in the onProjectLoaded() function.
kzResourceProfilingContextSampler(GenericResourceProfilingContext::Sampler, sampler, (getResourceManager()->getResourceProfiler().getMainThreadContextFactory(), "loadTexture", "texture url: " + textureUrl));
// This acquirement call loads and deploys the texture if the texture is not yet loaded or deployed.
// If the texture is already loaded and deployed, the above sampler does not create any context.
getResourceManager()->acquireResource<Texture>(textureUrl);
}
void onProjectLoaded() override
{
// Create a sampler which creates the "onProjectLoaded" resource profiling context if the loadTexture() function triggers resource loading.
kzResourceProfilingContextSampler(NamedResourceProfilingContext::Sampler, sampler, (getResourceManager()->getResourceProfiler().getMainThreadContextFactory(), "onProjectLoaded"));
loadTexture();
}
};