#include <StatisticalProfilerProxy.h>
Classes | |
class | TimedScope |
Public Types | |
using | StatIdType = AZ::Crc32 |
using | StatisticalProfilerType = StatisticalProfiler< StatIdType, AZStd::shared_mutex > |
Public Member Functions | |
AZ_TYPE_INFO (StatisticalProfilerProxy, "{1103D0EB-1C32-4854-B9D9-40A2D65BDBD2}") | |
StatisticalProfilerProxy (StatisticalProfilerProxy &&)=delete | |
StatisticalProfilerProxy & | operator= (StatisticalProfilerProxy &&)=delete |
void | RegisterProfilerId (StatisticalProfilerId id) |
bool | IsProfilerActive (StatisticalProfilerId id) const |
StatisticalProfilerType & | GetProfiler (StatisticalProfilerId id) |
void | ActivateProfiler (StatisticalProfilerId id, bool activate, bool autoCreate=true) |
void | PushSample (StatisticalProfilerId id, const StatIdType &statId, double value) |
void | GetAllStatistics (AZStd::vector< NamedRunningStatistic * > &stats) |
void | GetAllStatisticsOfUnits (AZStd::vector< NamedRunningStatistic * > &stats, const char *units) |
void | ResetAllStatistics () |
Friends | |
class | TimedScope |
This AZ::Interface<> (Yes, it is an application wide singleton) owns an array of StatisticalProfilers. When is this useful? When you need to statistically profile code that runs across DLL boundaries.
What is the meaning of "statistically profile" code? In regular profiling with tools like RAD Telemetry, every execution of a profiled scope of code will be captured when using AZ_PROFILE_SCOPE(). You can collect very large amounts of data and do your own post processing and analysis in tools like Excel,etc. In contrast, "statistical profiling" means that everytime AZ_PROFILE_SCOPE() is called, the time spent in the given scope of code will be mathematically accumulated as part of a unique Running statistic. Common statistical parameters like min, max, average, variance and standard deviation are calculated on the fly. This approach reduces considerably the amount of data that is collected. The data is recorded in the Game/Editor Log file.
This StatisticalProfilerProxy should be used via the AZ_PROFILE_SCOPE() macro, and by using this macro the developer gains the flexibility of switching at compile time between profiling the code via RAD Telemetry or through statistical profiling.
When creating a new statistical profiler add your category (aka profiler id) in Profiler.h (enum class ProfileCategory). Get a reference of the statistical profiler with "GetProfiler(const StatisticalProfilerId& id)" using the profiler Id. Once you get a reference to the profiler you can customize it, add Running statistics to it, etc. Some class in your code will manage the reference to the statistical profiler and will determine the policy on how often to log data to the game logs, etc. For example, by subclassing the TickBus Handler, etc.
The StatisticalProfilerProxySystemComponent guarantees that the StatisticalProfilerProxy singleton exists as soon as the AZ::Environment is fully initialized. See StatisticalProfiler.h for more details and info.