๐ Profiling Helper Macros
Short Description
Convenience macros for CPU tracing and CSV profiling that gracefully fall back when the profiler is not available.
Long Description
These macros wrap the engine tracing and CSV profiling APIs when present. When profiling is enabled the macros emit TRACE_CPUPROFILER_EVENT_SCOPE, CSV scoped stats and register inline CSV stats. When the profiler is not available the macros degrade to no-ops or to minimal trace calls so the same instrumentation can remain in shipping code with negligible overhead.
๐ Macros
GORGEOUS_PROFILE_SCOPE(StatName)
Scoped macro that emits a CPU profiler event and registers a CSV stat entry for StatName. When CSV profiler is not compiled in, it still emits a narrower trace event if available.
void SomeFunction()
{
GORGEOUS_PROFILE_SCOPE(SomeFunction);
// work
}
GORGEOUS_CSV_CUSTOM_STAT_SET(StatName, Value) / GORGEOUS_CSV_CUSTOM_STAT_ACCUMULATE(StatName, Value)
Record or accumulate a custom CSV stat when CSV profiling is available. These become no-ops otherwise.
GORGEOUS_CSV_CUSTOM_STAT_SET(MyCounter, 42);
GORGEOUS_CSV_CUSTOM_STAT_ACCUMULATE(MyCounter, Delta);
GORGEOUS_TRACE_BOOKMARK(Format, ...)
Lightweight wrapper around TRACE_BOOKMARK that is safe to call even when trace support is absent.
GORGEOUS_TRACE_BOOKMARK("PlayerCount=%d", PlayerCount);
Notes
- These instrumentation macros are designed to be left in performance-sensitive code. They automatically disable themselves (or reduce to minimal traces) when the required profiler subsystems are not present at compile time.
Where to find the header
src/content/gorgeous-core/RuntimeUtilities/Helpers/Headers/Macros/GorgeousProfilingHelperMacros.h