Profile

Profiling macros

Namespace: dmProfile
Include: #include <dmsdk/dlib/profile.h>
TYPES
HProfile Handle to a an active profile frame
ProfileIdx Index type to hold internal references of samplers and properties
ENUMS
PROFILE_PROPERTY_INVALID_IDX Index constant to mark a a property as invalid
ProfilePropertyFlags Set of bit flags to be used when declaring propertis
ProfilePropertyType Enum to describe type of a property
STRUCTS
struct ProfileListener Structure for registering a profile listener
FUNCTIONS
void ProfileFinalize() Finalize the profiling system
HProfile ProfileFrameBegin() Begin profiling, eg start of frame
void ProfileFrameEnd(HProfile profile) Release profile returned by #ProfileFrameBegin
void ProfileInitialize() Initialize the profiling system
bool ProfileIsInitialized() Finalize the profiling system
void ProfileLogText(const char* name,  ...) Log text via the registered profilers
void ProfilePropertyValue() Union to hold a property value
void ProfileRegisterProfiler(const char* name) Register a new profiler.
void ProfileScopeBegin(const char* name, uint64_t name_hash) Start a new profile scope
void ProfileScopeEnd(const char* name, uint64_t name_hash) End the last added scope
void ProfileSetThreadName(const char* name) Set the current thread name to each registered pro...
void ProfileUnregisterProfiler(const char* name) Unregister a profiler
MACROS
DM_PROFILE(a) add profile scope
DM_PROFILE_DYN(a, a) add dynamic profile scope
DM_PROFILE_TEXT(a, a) send text to the profiler
DM_PROPERTY_ADD_F32(name, value) add to float property
DM_PROPERTY_ADD_F64(name, value) add to double property
DM_PROPERTY_ADD_S32(name, value) add to int32_t property
DM_PROPERTY_ADD_S64(name, value) add to int64_t property
DM_PROPERTY_ADD_U32(name, value) add to uint32_t property
DM_PROPERTY_ADD_U64(name, value) add to uint64_t property
DM_PROPERTY_BOOL(name, default, flags, desc, group) bool property
DM_PROPERTY_EXTERN(name) Declare an extern property
DM_PROPERTY_F32(name, default, flags, desc, group) float property
DM_PROPERTY_F64(name, default, flags, desc, group) double property
DM_PROPERTY_GROUP(name, desc, parent) Declare a property group
DM_PROPERTY_RESET(name) reset property
DM_PROPERTY_S32(name, default, flags, desc, group) int32_t property
DM_PROPERTY_S64(name, default, flags, desc, group) int64_t property
DM_PROPERTY_SET_BOOL(name, value) set bool property
DM_PROPERTY_SET_F32(name, value) set float property
DM_PROPERTY_SET_F64(name, value) set double property
DM_PROPERTY_SET_S32(name, value) set int32_t property
DM_PROPERTY_SET_S64(name, value) set int64_t property
DM_PROPERTY_SET_U32(name, value) set uint32_t property
DM_PROPERTY_SET_U64(name, value) set uint64_t property
DM_PROPERTY_U32(name, default, flags, desc, group) uint32_t property
DM_PROPERTY_U64(name, default, flags, desc, group) uint64_t property

Functions

ProfileFinalize

void ProfileFinalize()

Finalize the profiling system

PARAMETERS


ProfileFrameBegin

HProfile ProfileFrameBegin()

Begin profiling, eg start of frame

PARAMETERS

RETURNS

HProfile The current profiling context. Must be released by #EndFrame

ProfileFrameEnd

void ProfileFrameEnd(HProfile profile)

Release profile returned by #ProfileFrameBegin

PARAMETERS

HProfile profile Profile to release

ProfileInitialize

void ProfileInitialize()

Initialize the profiling system

PARAMETERS


ProfileIsInitialized

bool ProfileIsInitialized()

Finalize the profiling system

PARAMETERS

RETURNS

bool Returns non zero if the profiler is initialized

ProfileLogText

void ProfileLogText(const char* name,  ...)

Log text via the registered profilers

PARAMETERS

const char* name Name of the scope
... Arguments for internal logging function

ProfilePropertyValue

void ProfilePropertyValue()

Union to hold a property value

PARAMETERS


ProfileRegisterProfiler

void ProfileRegisterProfiler(const char* name)

Register a new profiler. Can be done after the profiling has started.

PARAMETERS

const char* name Name of the profiler

ProfileScopeBegin

void ProfileScopeBegin(const char* name, uint64_t name_hash)

Start a new profile scope

PARAMETERS

const char* name Name of the scope
uint64_t name_hash Hashed name of the scope

ProfileScopeEnd

void ProfileScopeEnd(const char* name, uint64_t name_hash)

End the last added scope

PARAMETERS

const char* name Name of the scope
uint64_t name_hash Hashed name of the scope

ProfileSetThreadName

void ProfileSetThreadName(const char* name)

Set the current thread name to each registered profiler

PARAMETERS

const char* name Name of the thread

ProfileUnregisterProfiler

void ProfileUnregisterProfiler(const char* name)

Unregister a profiler

PARAMETERS

const char* name Name of the profiler

Structs

ProfileListener

TYPE

struct ProfileListener

Structure for registering a profile listener


Types

HProfile

Handle to a an active profile frame


ProfileIdx

Index type to hold internal references of samplers and properties


Enums

PROFILE_PROPERTY_INVALID_IDX

Index constant to mark a a property as invalid


ProfilePropertyFlags

Set of bit flags to be used when declaring propertis

PROFILE_PROPERTY_NONE
PROFILE_PROPERTY_FRAME_RESET

ProfilePropertyType

Enum to describe type of a property

PROFILE_PROPERTY_TYPE_GROUP
PROFILE_PROPERTY_TYPE_BOOL
PROFILE_PROPERTY_TYPE_S32
PROFILE_PROPERTY_TYPE_U32
PROFILE_PROPERTY_TYPE_F32
PROFILE_PROPERTY_TYPE_S64
PROFILE_PROPERTY_TYPE_U64
PROFILE_PROPERTY_TYPE_F64

Macros

DM_PROFILE

Adds a profiling scope. Excluded by default in release builds.

a A name for the scope

EXAMPLES

Profile a scope
{
    DM_PROFILE("DoWork");
    DoWork1();
    DoWork2();
}

DM_PROFILE_DYN

Adds a profiling scope. Excluded by default in release builds. Accepts a name cache value for performance.

a The scope name
a The scope name hash value pointer. May be 0.

EXAMPLES

Create a dynamic profiling scope
{
    DM_PROFILE_DYN(work->m_Name, &work->m_NameHash);
    work->DoWork();
}

DM_PROFILE_TEXT

Send text to the profiler

a The format string
a The variable argument list

EXAMPLES

Send a string to the profiler
DM_PROFILE_TEXT("Some value: %d", value);

DM_PROPERTY_ADD_F32

Add a value to float property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_F32(rmtp_MyValue, 1.5);

DM_PROPERTY_ADD_F64

Add a value to double property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_F64(rmtp_MyValue, 1.5);

DM_PROPERTY_ADD_S32

Add a value to int32_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_S32(rmtp_MyValue, -1);

DM_PROPERTY_ADD_S64

Add a value to int64_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_S64(rmtp_MyValue, -1);

DM_PROPERTY_ADD_U32

Add a value to uint32_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_U32(rmtp_MyValue, 1);

DM_PROPERTY_ADD_U64

Add a value to uint64_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_ADD_U64(rmtp_MyValue, 1);

DM_PROPERTY_BOOL

Declare a property of type bool

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_BOOL(rmtp_MyBool, 0, PROFILE_PROPERTY_FRAME_RESET, "true or false", &rmtp_MyGroup);

DM_PROPERTY_EXTERN

Declare an extern property

name The symbol name

EXAMPLES

Use a property declared elsewhere in the same library
DM_PROPERTY_EXTERN(rmtp_GameObject);
DM_PROPERTY_U32(rmtp_ComponentsAnim, 0, PROFILE_PROPERTY_FRAME_RESET, "#", &rmtp_GameObject);

DM_PROPERTY_F32

Declare a property of type float

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_F32(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);

DM_PROPERTY_F64

Declare a property of type double

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_F64(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);

DM_PROPERTY_GROUP

Declare a property group

name The group name
desc The description
parent pointer to parent property

EXAMPLES

DM_PROPERTY_GROUP(rmtp_GameObject, "My Group", 0);

DM_PROPERTY_RESET

Reset a property to its default value

name The property

EXAMPLES

DM_PROPERTY_RESET(rmtp_MyValue);

DM_PROPERTY_S32

Declare a property of type int32_t

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_S32(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);

DM_PROPERTY_S64

Declare a property of type int64_t

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_S64(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);

DM_PROPERTY_SET_BOOL

Set the value of a bool property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_BOOL(rmtp_MyBool, false);

DM_PROPERTY_SET_F32

Set the value of a float property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_F32(rmtp_MyValue, 1.5);

DM_PROPERTY_SET_F64

Set the value of a double property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_F64(rmtp_MyValue, 1.5);

DM_PROPERTY_SET_S32

Set the value of a int32_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_S32(rmtp_MyValue, -1);

DM_PROPERTY_SET_S64

Set the value of a int64_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_S64(rmtp_MyValue, -1);

DM_PROPERTY_SET_U32

Set the value of a uint32_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_U32(rmtp_MyValue, 1);

DM_PROPERTY_SET_U64

Set the value of a uint64_t property

name The property
value The value

EXAMPLES

DM_PROPERTY_SET_U64(rmtp_MyValue, 1);

DM_PROPERTY_U32

Declare a property of type uint32_t

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_U32(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);

DM_PROPERTY_U64

Declare a property of type uint64_t

name The property symbol/name
default The default value
flags The flags. Either PROFILE_PROPERTY_NONE or PROFILE_PROPERTY_FRAME_RESET. PROFILE_PROPERTY_FRAME_RESET makes the value reset each frame.
desc The description
group The parent group. May be 0.

EXAMPLES

DM_PROPERTY_U64(rmtp_MyValue, 0, PROFILE_PROPERTY_FRAME_RESET, "a value", &rmtp_MyGroup);