OpenTTD Source: anonymous_namespace{framerate_gui.cpp}::PerformanceData Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields | Static Public Attributes
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
std::array< TimingMeasurement, NUM_FRAMERATE_POINTS > | durations {}
| Time spent processing each cycle of the performance element, circular buffer.
std::array< TimingMeasurement, NUM_FRAMERATE_POINTS > | timestamps {}
| Start time of each cycle of the performance element, circular buffer.
double | expected_rate = 0
| Expected number of cycles per second when the system is running without slowdowns.
int | next_index = 0
| Next index to write to in `durations` and `timestamps`.
int | prev_index = 0
| Last index written to in `durations` and `timestamps`.
int | num_valid = 0
| 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 54 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_rate | Expected 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 82 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 85 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 110 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 116 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 96 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 129 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 153 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 72 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 74 of file framerate_gui.cpp.

## ◆ durations

std::array<TimingMeasurement, NUM_FRAMERATE_POINTS> anonymous_namespace{framerate_gui.cpp}::PerformanceData::durations {}

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

Definition at line 59 of file framerate_gui.cpp.

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

## ◆ expected_rate

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

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

Definition at line 63 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 56 of file framerate_gui.cpp.

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

## ◆ next_index

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

Next index to write to in `durations` and `timestamps`.

Definition at line 65 of file framerate_gui.cpp.

Referenced by PerformanceMeasurer::SetInactive().

## ◆ num_valid

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

Number of data points recorded, clamped to `NUM_FRAMERATE_POINTS`.

Definition at line 69 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 = 0

Last index written to in `durations` and `timestamps`.

Definition at line 67 of file framerate_gui.cpp.

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

## ◆ timestamps

std::array<TimingMeasurement, NUM_FRAMERATE_POINTS> anonymous_namespace{framerate_gui.cpp}::PerformanceData::timestamps {}

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

Definition at line 61 of file framerate_gui.cpp.

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

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

- src/framerate_gui.cpp