#include <StatisticalProfiler.h>
Classes | |
struct | StatisticalAggregate |
class | TimedScope |
Public Member Functions | |
StatisticalProfiler (const StatisticalProfiler &other) | |
StatisticalProfiler (StatisticalProfiler &&other) | |
AZ::Statistics::StatisticsManager< StatIdType > & | GetStatsManager () |
double | SummarizePerFrameStats () |
void | LogAndResetStats (const char *windowName) |
void | PushSample (const StatIdType &statId, double value) |
const AZ::Statistics::NamedRunningStatistic * | GetStatistic (const StatIdType &statId) |
int | AddPerFrameStatisticalAggregate (const AZStd::vector< StatIdType > &statIds, const StatIdType &timePerFrameStatId, const AZStd::string &timePerFrameStatName) |
const AZ::Statistics::NamedRunningStatistic * | GetFirstStatPerFrame () const |
Protected Attributes | |
MutexType | m_mutex |
Lock this before reading/writing to m_timeStatisticsManager, or else... | |
AZ::Statistics::StatisticsManager< StatIdType > | m_statisticsManager |
AZStd::vector< AZ::Statistics::NamedRunningStatistic * > | m_statsVector |
AZStd::vector< StatisticalAggregate > | m_perFrameAggregates |
Friends | |
class | TimedScope |
A helper class that facilitates collecting time spent in blocks (scopes) of code and aggregating the measured times as running statistics.
See "StatisticalProfilerProxy.h" for more explanations on the meaning of Statistical Profiling.
The StatisticalProfiler was made as a template to accommodate for several performance needs... If all the code that is being profiled is single threaded and you want to identify each statistic by its string name, then the default StatisticalProfiler<> works for you. If using a map<strings, stat> is too much of what you can afford, then index your statistics with an integer or crc32 and your code profiler should be declared as StatisticalProfiler<AZ::Crc32>. For multi-threaded cases and indexing statistic with Crc32 you can have a profiler like this: StatisticalProfiler<AZ::Crc32, AZStd::mutex>. The UnitTests mentioned in the first paragraph do benchmarks of different combinations of indexing and synchronization primitives.
Even though you can create, subclass and use your own StatisticalProfiler<*,*>, there are some things to consider when working with the StatisticalProfilerProxy: The StatisticalProfilerProxy OWNS an array of StatisticalProfiler<AZStd::string, AZStd::shared_mutex>. You can "manage" one of those StatisticalProfiler by getting a reference to it and add Running statistics etc.
|
inline |
Should be called once per frame, it runs over all existing timed stats in m_statsForPerFrameCalculation and accumulates all the values as a single stat per frame.