LDKProfilerZoneKind
typedef enum LDKProfilerZoneKind{
LDK_PROFILER_ZONE_USER=0,
LDK_PROFILER_ZONE_FRAME,
LDK_PROFILER_ZONE_PHASE,
LDK_PROFILER_ZONE_BUCKET,
LDK_PROFILER_ZONE_SYSTEM
}LDKProfilerZoneKind;
Lightweight engine profiling instrumentation.
The engine owns the collector in shared and monolithic builds.
typedef enum LDKProfilerZoneKind{
LDK_PROFILER_ZONE_USER=0,
LDK_PROFILER_ZONE_FRAME,
LDK_PROFILER_ZONE_PHASE,
LDK_PROFILER_ZONE_BUCKET,
LDK_PROFILER_ZONE_SYSTEM
}LDKProfilerZoneKind;
typedef struct LDKProfilerSource{
volatile i32 id;
}LDKProfilerSource;
typedef struct LDKProfilerCounter{
volatile i32 id;
}LDKProfilerCounter;
Initialize the profiler.
LDK_API bool ldk_profiler_initialize(const char *runtree_path);
const char *runtree_pathTrue if the operation succeeds; false otherwise.
Shut down the profiler.
LDK_API void ldk_profiler_terminate(void);
Start the profiler capture.
LDK_API bool ldk_profiler_capture_start(const char *path);
const char *pathTrue if the operation succeeds; false otherwise.
Stop the profiler capture.
LDK_API void ldk_profiler_capture_stop(void);
Collect the current profiler sample data.
LDK_API void ldk_profiler_capture_collect(bool enabled);
bool enabledToggle profiler capture state.
LDK_API void ldk_profiler_capture_toggle(void);
Check whether the profiler capture is active.
LDK_API bool ldk_profiler_capture_is_active(void);
True when the queried condition holds; false otherwise.
Get the profiler capture path.
LDK_API const char * ldk_profiler_capture_path_get(void);
Pointer to the requested object or data; NULL when unavailable.
Begin the profiler frame.
LDK_API void ldk_profiler_frame_begin(void);
Finish the profiler frame.
LDK_API void ldk_profiler_frame_end(void);
Begin a profiling zone tagged with a source location.
LDK_API void ldk_profiler_zone_begin_source(
LDKProfilerSource *source,
LDKProfilerZoneKind kind,
const char *name,
const char *file,
const char *function,
u32 line
);
LDKProfilerSource *sourceLDKProfilerZoneKind kindconst char *nameconst char *fileconst char *functionu32 lineFinish the profiler zone.
LDK_API void ldk_profiler_zone_end(void);
Close an active profiling zone of the specified kind.
LDK_API void ldk_profiler_zone_end_kind(LDKProfilerZoneKind kind);
LDKProfilerZoneKind kindAssign a profiler counter value at a source location.
LDK_API void ldk_profiler_counter_set_source(
LDKProfilerCounter *counter,
const char *name,
double value
);
LDKProfilerCounter *counterconst char *namedouble valueIncrement a profiler counter at a source location.
LDK_API void ldk_profiler_counter_add_source(
LDKProfilerCounter *counter,
const char *name,
double value
);
LDKProfilerCounter *counterconst char *namedouble valueSet the profiler thread name.
LDK_API void ldk_profiler_thread_name_set(const char *name);
const char *name#define LDK_PROFILE_CONCAT_INNER(a, b) a##b
#define LDK_PROFILE_CONCAT(a, b) LDK_PROFILE_CONCAT_INNER(a, b)
#define LDK_PROFILE_BEGIN(name) \
LDK_PROFILE_BEGIN_IMPL(name, __LINE__)
#define LDK_PROFILE_BEGIN_IMPL(name, line) \
do\
{\
static LDKProfilerSource LDK_PROFILE_CONCAT(\
ldk_profiler_source_, line)={0};\
ldk_profiler_zone_begin_source(\
&LDK_PROFILE_CONCAT(ldk_profiler_source_, line), \
LDK_PROFILER_ZONE_USER, (name), __FILE__, __func__, (u32)(line));\
}while(0)
#define LDK_PROFILE_END() ldk_profiler_zone_end()
#define LDK_PROFILE_COUNTER_SET(name, value) \
LDK_PROFILE_COUNTER_SET_IMPL(name, value, __LINE__)
#define LDK_PROFILE_COUNTER_SET_IMPL(name, value, line) \
do\
{\
static LDKProfilerCounter LDK_PROFILE_CONCAT(\
ldk_profiler_counter_, line)={0};\
ldk_profiler_counter_set_source(\
&LDK_PROFILE_CONCAT(ldk_profiler_counter_, line), (name), \
(double)(value));\
}while(0)
#define LDK_PROFILE_COUNTER_ADD(name, value) \
LDK_PROFILE_COUNTER_ADD_IMPL(name, value, __LINE__)
#define LDK_PROFILE_COUNTER_ADD_IMPL(name, value, line) \
do\
{\
static LDKProfilerCounter LDK_PROFILE_CONCAT(\
ldk_profiler_counter_, line)={0};\
ldk_profiler_counter_add_source(\
&LDK_PROFILE_CONCAT(ldk_profiler_counter_, line), (name), \
(double)(value));\
}while(0)