#include <PerformanceCollector.h>
Public Types | |
enum class | DataLogType { LogStatistics , LogAllSamples } |
using | OnBatchCompleteCallback = AZStd::function< void(AZ::u32 pendingBatchCount)> |
Public Member Functions | |
PerformanceCollector (const AZStd::string_view logCategory, AZStd::span< const AZStd::string_view > m_metricNames, OnBatchCompleteCallback onBatchCompleteCallback, const AZStd::string_view fileExtension="json") | |
bool | IsWaitingBeforeCapture () |
void | RecordSample (AZStd::string_view metricName, AZStd::chrono::microseconds microSeconds) |
Records a measured value according to the current CaptureType. | |
void | RecordPeriodicEvent (AZStd::string_view metricName) |
void | FrameTick () |
void | UpdateDataLogType (DataLogType newValue) |
void | UpdateFrameCountPerCaptureBatch (AZ::u32 newValue) |
void | UpdateWaitTimeBeforeEachBatch (AZStd::chrono::seconds seconds) |
void | UpdateNumberOfCaptureBatches (AZ::u32 newValue) |
const AZ::IO::Path & | GetOutputFilePath () const |
const AZStd::string & | GetOutputDataBuffer () const |
const AZStd::string & | GetFileExtension () const |
Static Public Attributes | |
static constexpr AZStd::string_view | AVG = "avg" |
Common properties found in the "args" dictionary of each Google Trace Json Row: | |
static constexpr AZStd::string_view | MIN = "min" |
static constexpr AZStd::string_view | MAX = "max" |
static constexpr AZStd::string_view | SAMPLE_COUNT = "sampleCount" |
static constexpr AZStd::string_view | UNITS = "units" |
static constexpr AZStd::string_view | VARIANCE = "variance" |
static constexpr AZStd::string_view | STDEV = "stdev" |
static constexpr AZStd::string_view | MOST_RECENT_SAMPLE = "mostRecentSampleValue" |
static constexpr char | LogName [] = "PerformanceCollector" |
A helper class that facilitates collecting performance metrics as part of blocks of code, or measuring time lapses of periodically called functions. The metrics can be recorded as raw events (DataLogType::LogAllSamples) or aggregated as statistical summaries (DataLogType::LogStatistics). Performance is captured in batches of frames.
using AZ::Debug::PerformanceCollector::OnBatchCompleteCallback = AZStd::function<void(AZ::u32 pendingBatchCount)> |
Function signature for the notification callback that will be dispatched each time a batch of frames are measured.
|
strong |
AZ::Debug::PerformanceCollector::PerformanceCollector | ( | const AZStd::string_view | logCategory, |
AZStd::span< const AZStd::string_view > | m_metricNames, | ||
OnBatchCompleteCallback | onBatchCompleteCallback, | ||
const AZStd::string_view | fileExtension = "json" |
||
) |
All metrics that will ever be recorded must be declared at construction time of the performance collector.
logCategory | Category name that will be used in the Google Trace output json file. Each output file will be named Performance_<Category>_<CreationTime>.json |
m_metricNames | List of all the metrics that will be recorded. All metrics will be measured in Microseconds. |
onBatchCompleteCallback | See comments above in OnBatchCompleteCallback declaration. |
m_fileExtension | The extension of the output file, to appear after "." Defaults to "json". |
void AZ::Debug::PerformanceCollector::FrameTick | ( | ) |
The user of the API must call this function each frame. This is where this class performs book keeping and decides when to flush data into the output files, etc.
bool AZ::Debug::PerformanceCollector::IsWaitingBeforeCapture | ( | ) |
Returns true if the user has disabled performance capture or the performance collector is waiting for certain amount of time before starting to measure performance.
void AZ::Debug::PerformanceCollector::RecordPeriodicEvent | ( | AZStd::string_view | metricName | ) |
This is similar to RecordSample(). Captures the elapsed time between two consecutive calls to this function for any given @metricName. The time delta is recorded according to the current CaptureType.
void AZ::Debug::PerformanceCollector::UpdateDataLogType | ( | DataLogType | newValue | ) |
Updates the kind of data collection and reporting. See @DataLogType for details. This function logs a warning and does nothing if a set of performance capture batches is already in effect.
void AZ::Debug::PerformanceCollector::UpdateFrameCountPerCaptureBatch | ( | AZ::u32 | newValue | ) |
Updates the number of frames that will be profiled per batch. This function logs a warning and does nothing if a set of performance capture batches is already in effect.
void AZ::Debug::PerformanceCollector::UpdateNumberOfCaptureBatches | ( | AZ::u32 | newValue | ) |
Calling this one with newValue > 0 will trigger json file creation and performance capture for as many batches.
void AZ::Debug::PerformanceCollector::UpdateWaitTimeBeforeEachBatch | ( | AZStd::chrono::seconds | seconds | ) |
Updates the amount of time to wait, in seconds, before each batch starts. This function logs a warning and does nothing if a set of performance capture batches is already in effect.