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 |
| ProfileResult | Enum to describe the result of a profiler operation |
| STRUCTS | |
|---|---|
| struct ProfileListener | Structure for registering a profile listener |
| struct ProfilePropertyValue | Union to hold a property value |
HProfile ProfileFrameBegin()
Begin profiling, eg start of frame
PARAMETERS
RETURNS
HProfile |
The current profiling context. Must be released by #EndFrame |
ProfileResult ProfileFrameEnd(HProfile profile)
Release profile returned by #ProfileFrameBegin
PARAMETERS
HProfile |
profile |
Profile to release |
RETURNS
ProfileResult |
Status for the frame end operation |
bool ProfileIsInitialized()
Finalize the profiling system
PARAMETERS
RETURNS
bool |
Returns non zero if the profiler is initialized |
ProfileResult ProfileLogText(const char* name, va_list ...)
Log text via the registered profilers
PARAMETERS
const char* |
name |
Name of the scope |
va_list |
... |
Arguments for internal logging function |
RETURNS
ProfileResult |
Status for the log text operation |
void ProfileRegisterProfiler(const char* name, ProfileListener* profiler)
Register a new profiler. Can be done after the profiling has started.
PARAMETERS
const char* |
name |
Name of the profiler. Only the first 15 characters are used to identify it. |
ProfileListener* |
profiler |
Instance of the profiler. Keep alive until calling ProfileUnregisterProfiler()! |
ProfileResult 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 |
RETURNS
ProfileResult |
Status for the scope begin operation |
ProfileResult 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 |
RETURNS
ProfileResult |
Status for the scope end operation |
ProfileResult ProfileSetThreadName(const char* name)
Set the current thread name to each registered profiler
PARAMETERS
const char* |
name |
Name of the thread |
RETURNS
ProfileResult |
Status for the thread name operation |
ProfileResult ProfileThreadEntered(const char* name)
Registers the current thread's name with each profiler. Called automatically for dmThread threads. Other threads may call this before their profiling work. Sample storage is allocated by the profiler as needed.
PARAMETERS
const char* |
name |
Name of the current thread |
RETURNS
ProfileResult |
Status for the thread entry operation |
ProfileResult ProfileThreadExited()
Releases the current thread's data in profilers supporting thread cleanup. Close profiling scopes before calling. Called automatically when a dmThread worker returns. Threads created outside dmThread must call this before exiting to release their data. Repeated calls without intervening profiling work are safe.
PARAMETERS
RETURNS
ProfileResult |
Status for the thread exit operation |
void ProfileUnregisterProfiler(const char* name)
Unregister a profiler
PARAMETERS
const char* |
name |
Name of the profiler. Only the first 15 characters are used to identify it. |
TYPE
struct ProfileListenerStructure for registering a profile listener
MEMBERS
ProfileThreadExitedFn |
m_ThreadExited |
Optional thread-exit callback. Release the current thread's data and allow repeated notifications. |
TYPE
struct ProfilePropertyValueUnion to hold a property value
MEMBERS
bool |
m_Bool |
Property value as a bool |
int32_t |
m_S32 |
Property value as a int32_t |
uint32_t |
m_U32 |
Property value as an uint32_t |
float |
m_F32 |
Property value as a float |
int64_t |
m_S64 |
Property value as a int64_t |
uint64_t |
m_U64 |
Property value as an uint64_t |
double |
m_F64 |
Property value as a double |
void HProfile()
Handle to a an active profile frame
PARAMETERS
void ProfileIdx()
Index type to hold internal references of samplers and properties
PARAMETERS
Index constant to mark a a property as invalid
Set of bit flags to be used when declaring propertis
PROFILE_PROPERTY_NONE |
|
PROFILE_PROPERTY_FRAME_RESET |
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 |
Enum to describe the result of a profiler operation
PROFILE_RESULT_OK |
|
PROFILE_RESULT_NOT_INITIALIZED |
|
PROFILE_RESULT_OUT_OF_SAMPLES |
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();
}
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();
}
Send text to the profiler
a |
The format string |
a |
The variable argument list |
EXAMPLES
Send a string to the profilerDM_PROFILE_TEXT("Some value: %d", value);
Add a value to float property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_F32(rmtp_MyValue, 1.5);
Add a value to double property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_F64(rmtp_MyValue, 1.5);
Add a value to int32_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_S32(rmtp_MyValue, -1);
Add a value to int64_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_S64(rmtp_MyValue, -1);
Add a value to uint32_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_U32(rmtp_MyValue, 1);
Add a value to uint64_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_ADD_U64(rmtp_MyValue, 1);
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);
Declare an extern property
name |
The symbol name |
EXAMPLES
Use a property declared elsewhere in the same libraryDM_PROPERTY_EXTERN(rmtp_GameObject);
DM_PROPERTY_U32(rmtp_ComponentsAnim, 0, PROFILE_PROPERTY_FRAME_RESET, "#", &rmtp_GameObject);
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);
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);
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);
Reset a property to its default value
name |
The property |
EXAMPLES
DM_PROPERTY_RESET(rmtp_MyValue);
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);
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);
Set the value of a bool property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_BOOL(rmtp_MyBool, false);
Set the value of a float property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_F32(rmtp_MyValue, 1.5);
Set the value of a double property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_F64(rmtp_MyValue, 1.5);
Set the value of a int32_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_S32(rmtp_MyValue, -1);
Set the value of a int64_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_S64(rmtp_MyValue, -1);
Set the value of a uint32_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_U32(rmtp_MyValue, 1);
Set the value of a uint64_t property
name |
The property |
value |
The value |
EXAMPLES
DM_PROPERTY_SET_U64(rmtp_MyValue, 1);
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);
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);