OpenTTD Source 20250206-master-g6089ed8059
anonymous_namespace{framerate_gui.cpp}::PerformanceData Struct Reference

Public Member Functions

 PerformanceData (double expected_rate)
 Initialize a data element with an expected collection rate.
 
void Add (TimingMeasurement start_time, TimingMeasurement end_time)
 Collect a complete measurement, given start and ending times for a processing block.
 
void BeginAccumulate (TimingMeasurement start_time)
 Begin an accumulation of multiple measurements into a single value, from a given start time.
 
void AddAccumulate (TimingMeasurement duration)
 Accumulate a period onto the current measurement.
 
void AddPause (TimingMeasurement start_time)
 Indicate a pause/expected discontinuity in processing the element.
 
double GetAverageDurationMilliseconds (int count)
 Get average cycle processing time over a number of data points.
 
double GetRate ()
 Get current rate of a performance element, based on approximately the past one second of data.
 

Data Fields

TimingMeasurement durations [NUM_FRAMERATE_POINTS]
 Time spent processing each cycle of the performance element, circular buffer.
 
TimingMeasurement timestamps [NUM_FRAMERATE_POINTS]
 Start time of each cycle of the performance element, circular buffer.
 
double expected_rate
 Expected number of cycles per second when the system is running without slowdowns.
 
int next_index
 Next index to write to in durations and timestamps.
 
int prev_index
 Last index written to in durations and timestamps.
 
int num_valid
 Number of data points recorded, clamped to NUM_FRAMERATE_POINTS.
 
TimingMeasurement acc_duration
 Current accumulated duration.
 
TimingMeasurement acc_timestamp
 Start time for current accumulation cycle.
 

Static Public Attributes

static const TimingMeasurement INVALID_DURATION = UINT64_MAX
 Duration value indicating the value is not valid should be considered a gap in measurements.
 

Detailed Description

Definition at line 50 of file framerate_gui.cpp.

Constructor & Destructor Documentation

◆ PerformanceData()

anonymous_namespace{framerate_gui.cpp}::PerformanceData::PerformanceData ( double  expected_rate)
inlineexplicit

Initialize a data element with an expected collection rate.

Parameters
expected_rateExpected number of cycles per second of the performance element. Use 1 if unknown or not relevant. The rate is used for highlighting slow-running elements in the GUI.

Definition at line 78 of file framerate_gui.cpp.

Member Function Documentation

◆ Add()

void anonymous_namespace{framerate_gui.cpp}::PerformanceData::Add ( TimingMeasurement  start_time,
TimingMeasurement  end_time 
)
inline

Collect a complete measurement, given start and ending times for a processing block.

Definition at line 81 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS.

Referenced by ProcessPendingPerformanceMeasurements(), and PerformanceMeasurer::~PerformanceMeasurer().

◆ AddAccumulate()

void anonymous_namespace{framerate_gui.cpp}::PerformanceData::AddAccumulate ( TimingMeasurement  duration)
inline

Accumulate a period onto the current measurement.

Definition at line 106 of file framerate_gui.cpp.

Referenced by PerformanceAccumulator::~PerformanceAccumulator().

◆ AddPause()

void anonymous_namespace{framerate_gui.cpp}::PerformanceData::AddPause ( TimingMeasurement  start_time)
inline

Indicate a pause/expected discontinuity in processing the element.

Definition at line 112 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS.

Referenced by PerformanceMeasurer::Paused().

◆ BeginAccumulate()

void anonymous_namespace{framerate_gui.cpp}::PerformanceData::BeginAccumulate ( TimingMeasurement  start_time)
inline

Begin an accumulation of multiple measurements into a single value, from a given start time.

Definition at line 92 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS.

Referenced by PerformanceAccumulator::Reset().

◆ GetAverageDurationMilliseconds()

double anonymous_namespace{framerate_gui.cpp}::PerformanceData::GetAverageDurationMilliseconds ( int  count)
inline

Get average cycle processing time over a number of data points.

Definition at line 125 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS, and anonymous_namespace{framerate_gui.cpp}::TIMESTAMP_PRECISION.

◆ GetRate()

double anonymous_namespace{framerate_gui.cpp}::PerformanceData::GetRate ( )
inline

Get current rate of a performance element, based on approximately the past one second of data.

Definition at line 149 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS, and anonymous_namespace{framerate_gui.cpp}::TIMESTAMP_PRECISION.

Field Documentation

◆ acc_duration

TimingMeasurement anonymous_namespace{framerate_gui.cpp}::PerformanceData::acc_duration

Current accumulated duration.

Definition at line 68 of file framerate_gui.cpp.

◆ acc_timestamp

TimingMeasurement anonymous_namespace{framerate_gui.cpp}::PerformanceData::acc_timestamp

Start time for current accumulation cycle.

Definition at line 70 of file framerate_gui.cpp.

◆ durations

TimingMeasurement anonymous_namespace{framerate_gui.cpp}::PerformanceData::durations[NUM_FRAMERATE_POINTS]

Time spent processing each cycle of the performance element, circular buffer.

Definition at line 55 of file framerate_gui.cpp.

Referenced by FrametimeGraphWindow::DrawWidget(), and FrametimeGraphWindow::UpdateScale().

◆ expected_rate

double anonymous_namespace{framerate_gui.cpp}::PerformanceData::expected_rate

Expected number of cycles per second when the system is running without slowdowns.

Definition at line 59 of file framerate_gui.cpp.

Referenced by PerformanceMeasurer::SetExpectedRate().

◆ INVALID_DURATION

const TimingMeasurement anonymous_namespace{framerate_gui.cpp}::PerformanceData::INVALID_DURATION = UINT64_MAX
static

Duration value indicating the value is not valid should be considered a gap in measurements.

Definition at line 52 of file framerate_gui.cpp.

Referenced by FrametimeGraphWindow::DrawWidget(), and FrametimeGraphWindow::UpdateScale().

◆ next_index

int anonymous_namespace{framerate_gui.cpp}::PerformanceData::next_index

Next index to write to in durations and timestamps.

Definition at line 61 of file framerate_gui.cpp.

Referenced by PerformanceMeasurer::SetInactive().

◆ num_valid

int anonymous_namespace{framerate_gui.cpp}::PerformanceData::num_valid

Number of data points recorded, clamped to NUM_FRAMERATE_POINTS.

Definition at line 65 of file framerate_gui.cpp.

Referenced by PerformanceMeasurer::SetInactive(), FrametimeGraphWindow::UpdateScale(), and PerformanceMeasurer::~PerformanceMeasurer().

◆ prev_index

int anonymous_namespace{framerate_gui.cpp}::PerformanceData::prev_index

Last index written to in durations and timestamps.

Definition at line 63 of file framerate_gui.cpp.

Referenced by FrametimeGraphWindow::DrawWidget(), PerformanceMeasurer::SetInactive(), and FrametimeGraphWindow::UpdateScale().

◆ timestamps

TimingMeasurement anonymous_namespace{framerate_gui.cpp}::PerformanceData::timestamps[NUM_FRAMERATE_POINTS]

Start time of each cycle of the performance element, circular buffer.

Definition at line 57 of file framerate_gui.cpp.

Referenced by FrametimeGraphWindow::DrawWidget(), and FrametimeGraphWindow::UpdateScale().


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