OpenTTD Source
20241108-master-g80f628063a
|
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 |
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.
PerformanceAccumulator::PerformanceAccumulator | ( | PerformanceElement | elem | ) |
Begin measuring one block of the accumulating value.
elem | The element to be measured |
Definition at line 308 of file framerate_gui.cpp.
References GetPerformanceTimer(), and PFE_MAX.
|
static |
Store the previous accumulator value and reset for a new cycle of accumulating measurements.
elem | The element to begin a new measurement cycle of |
Definition at line 327 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().