Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Debug::PerformanceCollector Class Referencefinal

#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::PathGetOutputFilePath () const
 
const AZStd::stringGetOutputDataBuffer () const
 
const AZStd::stringGetFileExtension () 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"
 

Detailed Description

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.

Member Typedef Documentation

◆ OnBatchCompleteCallback

Function signature for the notification callback that will be dispatched each time a batch of frames are measured.

Member Enumeration Documentation

◆ DataLogType

Enumerator
LogAllSamples 

Aggregates each sampled data using the StatiscalProfiler API. When done, a single record with statistical summary is dumped in the output file using the IEventLogger API.

Constructor & Destructor Documentation

◆ PerformanceCollector()

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.

Parameters
logCategoryCategory name that will be used in the Google Trace output json file. Each output file will be named Performance_<Category>_<CreationTime>.json
m_metricNamesList of all the metrics that will be recorded. All metrics will be measured in Microseconds.
onBatchCompleteCallbackSee comments above in OnBatchCompleteCallback declaration.
m_fileExtensionThe extension of the output file, to appear after "." Defaults to "json".

Member Function Documentation

◆ FrameTick()

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.

◆ IsWaitingBeforeCapture()

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.

◆ RecordPeriodicEvent()

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.

◆ UpdateDataLogType()

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.

◆ UpdateFrameCountPerCaptureBatch()

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.

◆ UpdateNumberOfCaptureBatches()

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.

◆ UpdateWaitTimeBeforeEachBatch()

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.


The documentation for this class was generated from the following file: