OpenTTD Source: src/framerate_type.h Source File

OpenTTD Source 15.3

framerate_type.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
35#ifndef FRAMERATE_TYPE_H
36#define FRAMERATE_TYPE_H
37
38#include "core/enum_type.hpp"
39
46 enum PerformanceElement : uint8_t {
47 PFE_FIRST = 0,
48 PFE_GAMELOOP = 0,
49 PFE_GL_ECONOMY,
50 PFE_GL_TRAINS,
51 PFE_GL_ROADVEHS,
52 PFE_GL_SHIPS,
53 PFE_GL_AIRCRAFT,
54 PFE_GL_LANDSCAPE,
55 PFE_GL_LINKGRAPH,
56 PFE_DRAWING,
57 PFE_DRAWWORLD,
58 PFE_VIDEO,
59 PFE_SOUND,
60 PFE_ALLSCRIPTS,
61 PFE_GAMESCRIPT,
62 PFE_AI0,
63 PFE_AI1,
64 PFE_AI2,
65 PFE_AI3,
66 PFE_AI4,
67 PFE_AI5,
68 PFE_AI6,
69 PFE_AI7,
70 PFE_AI8,
71 PFE_AI9,
72 PFE_AI10,
73 PFE_AI11,
74 PFE_AI12,
75 PFE_AI13,
76 PFE_AI14,
77 PFE_MAX,
78};
79 DECLARE_INCREMENT_DECREMENT_OPERATORS(PerformanceElement)
80
81
82typedef uint64_t TimingMeasurement;
83
91class PerformanceMeasurer {
92 PerformanceElement elem;
93 TimingMeasurement start_time;
94public:
95 PerformanceMeasurer(PerformanceElement elem);
96 ~PerformanceMeasurer();
97 void SetExpectedRate(double rate);
98 static void SetInactive(PerformanceElement elem);
99 static void Paused(PerformanceElement elem);
100};
101
113 class PerformanceAccumulator {
114 PerformanceElement elem;
115 TimingMeasurement start_time;
116public:
117 PerformanceAccumulator(PerformanceElement elem);
118 ~PerformanceAccumulator();
119 static void Reset(PerformanceElement elem);
120};
121
122void ShowFramerateWindow();
123void ProcessPendingPerformanceMeasurements();
124
125#endif /* FRAMERATE_TYPE_H */
PerformanceAccumulator
RAII class for measuring multi-step elements of performance.
Definition framerate_type.h:113
PerformanceAccumulator::~PerformanceAccumulator
~PerformanceAccumulator()
Finish and add one block of the accumulating value.
Definition framerate_gui.cpp:322
PerformanceAccumulator::Reset
static void Reset(PerformanceElement elem)
Store the previous accumulator value and reset for a new cycle of accumulating measurements.
Definition framerate_gui.cpp:332
PerformanceMeasurer
RAII class for measuring simple elements of performance.
Definition framerate_type.h:91
enum_type.hpp
Type (helpers) for enums.
DECLARE_INCREMENT_DECREMENT_OPERATORS
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:63
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition framerate_gui.cpp:986
ProcessPendingPerformanceMeasurements
void ProcessPendingPerformanceMeasurements()
This drains the PFE_SOUND measurement data queue into _pf_data.
Definition framerate_gui.cpp:1067
PerformanceElement
PerformanceElement
Elements of game performance that can be measured.
Definition framerate_type.h:46
PFE_AI6
@ PFE_AI6
AI execution for player slot 7.
Definition framerate_type.h:68
PFE_AI1
@ PFE_AI1
AI execution for player slot 2.
Definition framerate_type.h:63
PFE_GAMELOOP
@ PFE_GAMELOOP
Speed of gameloop processing.
Definition framerate_type.h:48
PFE_AI9
@ PFE_AI9
AI execution for player slot 10.
Definition framerate_type.h:71
PFE_GL_SHIPS
@ PFE_GL_SHIPS
Time spent processing ships.
Definition framerate_type.h:52
PFE_AI3
@ PFE_AI3
AI execution for player slot 4.
Definition framerate_type.h:65
PFE_AI4
@ PFE_AI4
AI execution for player slot 5.
Definition framerate_type.h:66
PFE_AI11
@ PFE_AI11
AI execution for player slot 12.
Definition framerate_type.h:73
PFE_AI8
@ PFE_AI8
AI execution for player slot 9.
Definition framerate_type.h:70
PFE_GAMESCRIPT
@ PFE_GAMESCRIPT
Game script execution.
Definition framerate_type.h:61
PFE_VIDEO
@ PFE_VIDEO
Speed of painting drawn video buffer.
Definition framerate_type.h:58
PFE_GL_LINKGRAPH
@ PFE_GL_LINKGRAPH
Time spent waiting for link graph background jobs.
Definition framerate_type.h:55
PFE_AI13
@ PFE_AI13
AI execution for player slot 14.
Definition framerate_type.h:75
PFE_AI7
@ PFE_AI7
AI execution for player slot 8.
Definition framerate_type.h:69
PFE_GL_AIRCRAFT
@ PFE_GL_AIRCRAFT
Time spent processing aircraft.
Definition framerate_type.h:53
PFE_GL_ECONOMY
@ PFE_GL_ECONOMY
Time spent processing cargo movement.
Definition framerate_type.h:49
PFE_AI0
@ PFE_AI0
AI execution for player slot 1.
Definition framerate_type.h:62
PFE_DRAWING
@ PFE_DRAWING
Speed of drawing world and GUI.
Definition framerate_type.h:56
PFE_AI12
@ PFE_AI12
AI execution for player slot 13.
Definition framerate_type.h:74
PFE_AI2
@ PFE_AI2
AI execution for player slot 3.
Definition framerate_type.h:64
PFE_AI10
@ PFE_AI10
AI execution for player slot 11.
Definition framerate_type.h:72
PFE_GL_LANDSCAPE
@ PFE_GL_LANDSCAPE
Time spent processing other world features.
Definition framerate_type.h:54
PFE_GL_ROADVEHS
@ PFE_GL_ROADVEHS
Time spend processing road vehicles.
Definition framerate_type.h:51
PFE_GL_TRAINS
@ PFE_GL_TRAINS
Time spent processing trains.
Definition framerate_type.h:50
PFE_MAX
@ PFE_MAX
End of enum, must be last.
Definition framerate_type.h:77
PFE_ALLSCRIPTS
@ PFE_ALLSCRIPTS
Sum of all GS/AI scripts.
Definition framerate_type.h:60
PFE_SOUND
@ PFE_SOUND
Speed of mixing audio samples.
Definition framerate_type.h:59
PFE_DRAWWORLD
@ PFE_DRAWWORLD
Time spent drawing world viewports in GUI.
Definition framerate_type.h:57
PFE_AI14
@ PFE_AI14
AI execution for player slot 15.
Definition framerate_type.h:76
PFE_AI5
@ PFE_AI5
AI execution for player slot 6.
Definition framerate_type.h:67
TimingMeasurement
uint64_t TimingMeasurement
Type used to hold a performance timing measurement.
Definition framerate_type.h:82