OpenTTD Source: PerformanceAccumulator Class Reference

OpenTTD Source 1.11.0-RC1

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

RAII class for measuring multi-step elements of performance. More...

`#include <framerate_type.h>`

## Public Member Functions
| PerformanceAccumulator (PerformanceElement elem)
| Begin measuring one block of the accumulating value. More...
| ~PerformanceAccumulator ()
| Finish and add one block of the accumulating value.

## Static Public Member Functions
static void | Reset (PerformanceElement elem)
| Store the previous accumulator value and reset for a new cycle of accumulating measurements. More...

## Private Attributes
PerformanceElement | elem
TimingMeasurement | start_time

## Detailed Description

RAII class for measuring multi-step elements of performance.

At the beginning of a frame, call Reset on the element, then construct an object in the scope where each processing cycle happens. The measurements are summed between resets.

Usually StateGameLoop is an appropriate function to place Reset calls in, but for elements with more isolated scopes it can also be appropriate to Reset somewhere else. An example is the CallVehicleTicks function where all the vehicle type elements are reset.

The PerformanceMeasurer::Paused function can also be used with elements otherwise measured with this class.

Definition at line 114 of file framerate_type.h.

## Constructor & Destructor Documentation

## ◆ PerformanceAccumulator()

PerformanceAccumulator::PerformanceAccumulator | ( | PerformanceElement | elem | ) |

Begin measuring one block of the accumulating value.

Parameters

  elem | The element to be measured

Definition at line 286 of file framerate_gui.cpp.

References GetPerformanceTimer(), and PFE_MAX.

## Member Function Documentation

## ◆ Reset()

void PerformanceAccumulator::Reset | ( | PerformanceElement | elem | ) |
| static

Store the previous accumulator value and reset for a new cycle of accumulating measurements.

Note
  This function must be called once per frame, otherwise measurements are not collected.

Parameters

  elem | The element to begin a new measurement cycle of

Definition at line 305 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::_pf_data, anonymous_namespace{framerate_gui.cpp}::PerformanceData::BeginAccumulate(), and GetPerformanceTimer().

Referenced by StateGameLoop(), and UpdateWindows().

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

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