OpenTTD Source: src/framerate_type.h Source File

OpenTTD Source 14.1

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 <http://www.gnu.org/licenses/>.
6 */
7
35 #ifndef FRAMERATE_TYPE_H
36 #define FRAMERATE_TYPE_H
37
38 #include "stdafx.h"
39 #include "core/enum_type.hpp"
40
47 enum PerformanceElement {
48 PFE_FIRST = 0,
49 PFE_GAMELOOP = 0,
50 PFE_GL_ECONOMY,
51 PFE_GL_TRAINS,
52 PFE_GL_ROADVEHS,
53 PFE_GL_SHIPS,
54 PFE_GL_AIRCRAFT,
55 PFE_GL_LANDSCAPE,
56 PFE_GL_LINKGRAPH,
57 PFE_DRAWING,
58 PFE_DRAWWORLD,
59 PFE_VIDEO,
60 PFE_SOUND,
61 PFE_ALLSCRIPTS,
62 PFE_GAMESCRIPT,
63 PFE_AI0,
64 PFE_AI1,
65 PFE_AI2,
66 PFE_AI3,
67 PFE_AI4,
68 PFE_AI5,
69 PFE_AI6,
70 PFE_AI7,
71 PFE_AI8,
72 PFE_AI9,
73 PFE_AI10,
74 PFE_AI11,
75 PFE_AI12,
76 PFE_AI13,
77 PFE_AI14,
78 PFE_MAX,
79 };
80 DECLARE_POSTFIX_INCREMENT(PerformanceElement)
81
82
83 typedef uint64_t TimingMeasurement;
84
92 class PerformanceMeasurer {
93 PerformanceElement elem;
94 TimingMeasurement start_time;
95 public:
96 PerformanceMeasurer(PerformanceElement elem);
97 ~PerformanceMeasurer();
98 void SetExpectedRate(double rate);
99 static void SetInactive(PerformanceElement elem);
100 static void Paused(PerformanceElement elem);
101 };
102
114 class PerformanceAccumulator {
115 PerformanceElement elem;
116 TimingMeasurement start_time;
117 public:
118 PerformanceAccumulator(PerformanceElement elem);
119 ~PerformanceAccumulator();
120 static void Reset(PerformanceElement elem);
121 };
122
123 void ShowFramerateWindow();
124 void ProcessPendingPerformanceMeasurements();
125
126 #endif /* FRAMERATE_TYPE_H */
PFE_AI11
@ PFE_AI11
AI execution for player slot 12.
Definition: framerate_type.h:74
PFE_AI9
@ PFE_AI9
AI execution for player slot 10.
Definition: framerate_type.h:72
PFE_VIDEO
@ PFE_VIDEO
Speed of painting drawn video buffer.
Definition: framerate_type.h:59
PFE_AI14
@ PFE_AI14
AI execution for player slot 15.
Definition: framerate_type.h:77
PFE_AI1
@ PFE_AI1
AI execution for player slot 2.
Definition: framerate_type.h:64
PFE_GL_ROADVEHS
@ PFE_GL_ROADVEHS
Time spend processing road vehicles.
Definition: framerate_type.h:52
PerformanceMeasurer
RAII class for measuring simple elements of performance.
Definition: framerate_type.h:92
PFE_GL_LINKGRAPH
@ PFE_GL_LINKGRAPH
Time spent waiting for link graph background jobs.
Definition: framerate_type.h:56
PerformanceAccumulator::~PerformanceAccumulator
~PerformanceAccumulator()
Finish and add one block of the accumulating value.
Definition: framerate_gui.cpp:317
TimingMeasurement
uint64_t TimingMeasurement
Type used to hold a performance timing measurement.
Definition: framerate_type.h:83
PFE_GL_LANDSCAPE
@ PFE_GL_LANDSCAPE
Time spent processing other world features.
Definition: framerate_type.h:55
PerformanceElement
PerformanceElement
Elements of game performance that can be measured.
Definition: framerate_type.h:47
PFE_GL_TRAINS
@ PFE_GL_TRAINS
Time spent processing trains.
Definition: framerate_type.h:51
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
PFE_AI7
@ PFE_AI7
AI execution for player slot 8.
Definition: framerate_type.h:70
PFE_GL_SHIPS
@ PFE_GL_SHIPS
Time spent processing ships.
Definition: framerate_type.h:53
PFE_AI2
@ PFE_AI2
AI execution for player slot 3.
Definition: framerate_type.h:65
PFE_DRAWING
@ PFE_DRAWING
Speed of drawing world and GUI.
Definition: framerate_type.h:57
PFE_AI12
@ PFE_AI12
AI execution for player slot 13.
Definition: framerate_type.h:75
PFE_GL_AIRCRAFT
@ PFE_GL_AIRCRAFT
Time spent processing aircraft.
Definition: framerate_type.h:54
PFE_AI10
@ PFE_AI10
AI execution for player slot 11.
Definition: framerate_type.h:73
PFE_MAX
@ PFE_MAX
End of enum, must be last.
Definition: framerate_type.h:78
stdafx.h
PerformanceAccumulator
RAII class for measuring multi-step elements of performance.
Definition: framerate_type.h:114
PFE_GAMESCRIPT
@ PFE_GAMESCRIPT
Game script execution.
Definition: framerate_type.h:62
PerformanceAccumulator::PerformanceAccumulator
PerformanceAccumulator(PerformanceElement elem)
Begin measuring one block of the accumulating value.
Definition: framerate_gui.cpp:308
PFE_SOUND
@ PFE_SOUND
Speed of mixing audio samples.
Definition: framerate_type.h:60
PFE_GAMELOOP
@ PFE_GAMELOOP
Speed of gameloop processing.
Definition: framerate_type.h:49
PFE_AI8
@ PFE_AI8
AI execution for player slot 9.
Definition: framerate_type.h:71
PFE_GL_ECONOMY
@ PFE_GL_ECONOMY
Time spent processing cargo movement.
Definition: framerate_type.h:50
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition: framerate_gui.cpp:1030
PFE_AI3
@ PFE_AI3
AI execution for player slot 4.
Definition: framerate_type.h:66
PFE_AI6
@ PFE_AI6
AI execution for player slot 7.
Definition: framerate_type.h:69
PFE_ALLSCRIPTS
@ PFE_ALLSCRIPTS
Sum of all GS/AI scripts.
Definition: framerate_type.h:61
enum_type.hpp
PFE_AI5
@ PFE_AI5
AI execution for player slot 6.
Definition: framerate_type.h:68
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:327
PFE_AI13
@ PFE_AI13
AI execution for player slot 14.
Definition: framerate_type.h:76
ProcessPendingPerformanceMeasurements
void ProcessPendingPerformanceMeasurements()
This drains the PFE_SOUND measurement data queue into _pf_data.
Definition: framerate_gui.cpp:1113
PFE_AI4
@ PFE_AI4
AI execution for player slot 5.
Definition: framerate_type.h:67
PFE_AI0
@ PFE_AI0
AI execution for player slot 1.
Definition: framerate_type.h:63
PFE_DRAWWORLD
@ PFE_DRAWWORLD
Time spent drawing world viewports in GUI.
Definition: framerate_type.h:58