$darkmode
High-precision performance measurement (CPU and GPU). More...
Go to the source code of this file.
Data Structures | |
| struct | PerfTimer |
| CPU high-precision timer. More... | |
| struct | GPUTimer |
| GPU performance timer using OpenGL Query Objects. More... | |
| struct | HybridTimer |
| Hybrid timer combining CPU and GPU measurements. More... | |
| struct | HybridTimerRAII |
| Internal helper for scope-based timing. More... | |
Macros | |
| #define | PERF_MEASURE_MS(var_name) |
Automatically measures a code block and stores result in var_name. More... | |
| #define | PERF_MEASURE_LOG(label) |
| Automatically measures and logs a code block to the "perf" category. More... | |
| #define | GPU_MEASURE_MS(var_name) |
Automatically measures a GPU block and stores result in var_name. More... | |
| #define | GPU_MEASURE_LOG(label) |
| Automatically measures and logs a GPU block to "perf.gpu". More... | |
| #define | HYBRID_MEASURE_LOG(label) |
| Hybrid measurement macro. Useful for identifying driver vs GPU bottlenecks. More... | |
| #define | HYBRID_MEASURE_DEBUG_MS(var_name, label) |
| Hybrid measurement with DEBUG-level console logging. More... | |
| #define | HYBRID_FUNC_TIMER(label) |
| Scoped hybrid timer. Automatically logs on scope exit. More... | |
Functions | |
| void | perf_timer_start (PerfTimer *timer) |
| Starts the CPU timer. More... | |
| double | perf_timer_elapsed_ms (PerfTimer *timer) |
| Stops the timer and returns elapsed time in milliseconds. More... | |
| double | perf_timer_elapsed_us (PerfTimer *timer) |
| Stops the timer and returns elapsed time in microseconds. More... | |
| double | perf_timer_elapsed_s (PerfTimer *timer) |
| Stops the timer and returns elapsed time in seconds. More... | |
| void | gpu_timer_start (GPUTimer *timer) |
| Initializes and starts a GPU measurement. More... | |
| void | gpu_timer_stop (GPUTimer *timer) |
| Explicitly stops the GPU timer (records end timestamp). More... | |
| double | gpu_timer_elapsed_ms (GPUTimer *timer, int wait_for_result) |
| Stops the GPU timer and retrieves the result. More... | |
| void | gpu_timer_cleanup (GPUTimer *timer) |
| Releases OpenGL resources associated with the GPU timer. More... | |
| HybridTimer | perf_hybrid_start (void) |
| Starts both CPU and GPU measurement simultaneously. More... | |
| void | perf_hybrid_stop (HybridTimer *timer, const char *label) |
| Stops both measurements and logs the results to the console. More... | |
| double | perf_hybrid_stop_debug (HybridTimer *timer, const char *label) |
| Like perf_hybrid_stop, but logs at DEBUG level instead of INFO. More... | |
| static void | hybrid_timer_cleanup_raii (HybridTimerRAII *timer_raii) |
| Internal cleanup function for HybridTimerRAII. More... | |
High-precision performance measurement (CPU and GPU).
This module provides timers for measuring CPU wall-clock time using clock_gettime and GPU execution time using OpenGL timer queries. It also includes RAII-style macros for automatic profiling.
| #define GPU_MEASURE_LOG | ( | label | ) |
Automatically measures and logs a GPU block to "perf.gpu".
| #define GPU_MEASURE_MS | ( | var_name | ) |
Automatically measures a GPU block and stores result in var_name.
| #define HYBRID_FUNC_TIMER | ( | label | ) |
Scoped hybrid timer. Automatically logs on scope exit.
Usage:
| #define HYBRID_MEASURE_DEBUG_MS | ( | var_name, | |
| label | |||
| ) |
Hybrid measurement with DEBUG-level console logging.
Like HYBRID_MEASURE_LOG but demotes console output to LOG_DEBUG. Tracy zones are still emitted. Captures GPU elapsed ms into var_name.
Usage:
| #define HYBRID_MEASURE_LOG | ( | label | ) |
Hybrid measurement macro. Useful for identifying driver vs GPU bottlenecks.
| #define PERF_MEASURE_LOG | ( | label | ) |
Automatically measures and logs a code block to the "perf" category.
| #define PERF_MEASURE_MS | ( | var_name | ) |
Automatically measures a code block and stores result in var_name.
Usage:
| void gpu_timer_cleanup | ( | GPUTimer * | timer | ) |
Releases OpenGL resources associated with the GPU timer.
| timer | Pointer to the timer. |
| double gpu_timer_elapsed_ms | ( | GPUTimer * | timer, |
| int | wait_for_result | ||
| ) |
Stops the GPU timer and retrieves the result.
| timer | Pointer to the timer. |
| wait_for_result | If true, blocks until the GPU is finished and result is ready. |
| void gpu_timer_start | ( | GPUTimer * | timer | ) |
Initializes and starts a GPU measurement.
| timer | Pointer to the timer. |
| void gpu_timer_stop | ( | GPUTimer * | timer | ) |
Explicitly stops the GPU timer (records end timestamp).
| timer | Pointer to the timer. |
|
inlinestatic |
Internal cleanup function for HybridTimerRAII.
| HybridTimer perf_hybrid_start | ( | void | ) |
Starts both CPU and GPU measurement simultaneously.
| void perf_hybrid_stop | ( | HybridTimer * | timer, |
| const char * | label | ||
| ) |
Stops both measurements and logs the results to the console.
| timer | Pointer to the timer. |
| label | Descriptive string for the log entry. |
| double perf_hybrid_stop_debug | ( | HybridTimer * | timer, |
| const char * | label | ||
| ) |
Like perf_hybrid_stop, but logs at DEBUG level instead of INFO.
Tracy zones are still emitted at full detail. Only the console output is demoted to reduce noise in production. Returns GPU elapsed ms.
| timer | Pointer to the timer. |
| label | Descriptive string for the log entry. |
| double perf_timer_elapsed_ms | ( | PerfTimer * | timer | ) |
Stops the timer and returns elapsed time in milliseconds.
| timer | Pointer to the timer. |
| double perf_timer_elapsed_s | ( | PerfTimer * | timer | ) |
Stops the timer and returns elapsed time in seconds.
| timer | Pointer to the timer. |
| double perf_timer_elapsed_us | ( | PerfTimer * | timer | ) |
Stops the timer and returns elapsed time in microseconds.
| timer | Pointer to the timer. |
| void perf_timer_start | ( | PerfTimer * | timer | ) |
Starts the CPU timer.
| timer | Pointer to the timer. |