OpenTTD Source: PerformanceMeasurer Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Static Public Member Functions | Private Attributes
PerformanceMeasurer Class Reference

RAII class for measuring simple elements of performance. More...

`#include <framerate_type.h>`

## Public Member Functions
| PerformanceMeasurer (PerformanceElement elem)
| Begin a cycle of a measured element.
| ~PerformanceMeasurer ()
| Finish a cycle of a measured element and store the measurement taken.
void | SetExpectedRate (double rate)
| Set the rate of expected cycles per second of a performance element.

## Static Public Member Functions
static void | SetInactive (PerformanceElement elem)
| Mark a performance element as not currently in use.
static void | Paused (PerformanceElement elem)
| Indicate that a cycle of "pause" where no processing occurs.

## Private Attributes
PerformanceElement | elem
TimingMeasurement | start_time

## Detailed Description

RAII class for measuring simple elements of performance.

Construct an object with the appropriate element parameter when processing begins, time is automatically taken when the object goes out of scope again.

Call Paused at the start of a frame if the processing of this element is paused.

Definition at line 91 of file framerate_type.h.

## Constructor & Destructor Documentation

## ◆ PerformanceMeasurer()

PerformanceMeasurer::PerformanceMeasurer | ( | PerformanceElement | elem | ) |

Begin a cycle of a measured element.

Parameters

  elem | The element to be measured

Definition at line 247 of file framerate_gui.cpp.

References GetPerformanceTimer(), and PFE_MAX.

## ◆ ~PerformanceMeasurer()

PerformanceMeasurer::~PerformanceMeasurer | ( |  | ) |

Finish a cycle of a measured element and store the measurement taken.

Definition at line 256 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::PerformanceData::Add(), GetPerformanceTimer(), anonymous_namespace{framerate_gui.cpp}::PerformanceData::num_valid, PFE_AI0, PFE_ALLSCRIPTS, PFE_GAMESCRIPT, PFE_MAX, PFE_SOUND, and SetInactive().

## Member Function Documentation

## ◆ Paused()

void PerformanceMeasurer::Paused | ( | PerformanceElement | elem | ) |
| static

Indicate that a cycle of "pause" where no processing occurs.

Parameters

  elem | The element not currently being processed

Definition at line 302 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::PerformanceData::AddPause(), GetPerformanceTimer(), and SetInactive().

Referenced by StateGameLoop().

## ◆ SetExpectedRate()

void PerformanceMeasurer::SetExpectedRate | ( | double | rate | ) |

Set the rate of expected cycles per second of a performance element.

Definition at line 285 of file framerate_gui.cpp.

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

## ◆ SetInactive()

void PerformanceMeasurer::SetInactive | ( | PerformanceElement | elem | ) |
| static

Mark a performance element as not currently in use.

Definition at line 291 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::PerformanceData::next_index, anonymous_namespace{framerate_gui.cpp}::PerformanceData::num_valid, and anonymous_namespace{framerate_gui.cpp}::PerformanceData::prev_index.

Referenced by AI::GameLoop(), Game::GameLoop(), OnTick_LinkGraph(), Paused(), AI::Stop(), and ~PerformanceMeasurer().

## Field Documentation

## ◆ elem

PerformanceElement PerformanceMeasurer::elem
| private

Definition at line 92 of file framerate_type.h.

## ◆ start_time

TimingMeasurement PerformanceMeasurer::start_time
| private

Definition at line 93 of file framerate_type.h.

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

- src/framerate_type.h
- src/framerate_gui.cpp