Debian Codegraph @

doc/classes/Performance.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="Performance" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Exposes performance-related data.
5 </brief_description>
6 <description>
7 This class provides access to a number of different monitors related to performance, such as memory usage, draw calls, and FPS. These are the same as the values displayed in the [b]Monitor[/b] tab in the editor's [b]Debugger[/b] panel. By using the [method get_monitor] method of this class, you can access this data from your code.
8 You can add custom monitors using the [method add_custom_monitor] method. Custom monitors are available in [b]Monitor[/b] tab in the editor's [b]Debugger[/b] panel together with built-in monitors.
9 [b]Note:[/b] Some of the built-in monitors are only available in debug mode and will always return [code]0[/code] when used in a project exported in release mode.
10 [b]Note:[/b] Some of the built-in monitors are not updated in real-time for performance reasons, so there may be a delay of up to 1 second between changes.
11 [b]Note:[/b] Custom monitors do not support negative values. Negative values are clamped to 0.
12 </description>
13 <tutorials>
14 </tutorials>
15 <methods>
16 <method name="add_custom_monitor">
17 <return type="void" />
18 <param index="0" name="id" type="StringName" />
19 <param index="1" name="callable" type="Callable" />
20 <param index="2" name="arguments" type="Array" default="[]" />
21 <param index="3" name="type" type="int" enum="Performance.MonitorType" default="0" />
22 <description>
23 Adds a custom monitor with the name [param id]. You can specify the category of the monitor using slash delimiters in [param id] (for example: [code]"Game/NumberOfNPCs"[/code]). If there is more than one slash delimiter, then the default category is used. The default category is [code]"Custom"[/code]. Prints an error if given [param id] is already present.
24 [codeblocks]
25 [gdscript]
26 func _ready():
27 var monitor_value = Callable(self, "get_monitor_value")
28
29 # Adds monitor with name "MyName" to category "MyCategory".
30 Performance.add_custom_monitor("MyCategory/MyMonitor", monitor_value)
31
32 # Adds monitor with name "MyName" to category "Custom".
33 # Note: "MyCategory/MyMonitor" and "MyMonitor" have same name but different IDs, so the code is valid.
34 Performance.add_custom_monitor("MyMonitor", monitor_value)
35
36 # Adds monitor with name "MyName" to category "Custom".
37 # Note: "MyMonitor" and "Custom/MyMonitor" have same name and same category but different IDs, so the code is valid.
38 Performance.add_custom_monitor("Custom/MyMonitor", monitor_value)
39
40 # Adds monitor with name "MyCategoryOne/MyCategoryTwo/MyMonitor" to category "Custom".
41 Performance.add_custom_monitor("MyCategoryOne/MyCategoryTwo/MyMonitor", monitor_value)
42
43 func get_monitor_value():
44 return randi() % 25
45 [/gdscript]
46 [csharp]
47 public override void _Ready()
48 {
49 var monitorValue = new Callable(this, MethodName.GetMonitorValue);
50
51 // Adds monitor with name "MyName" to category "MyCategory".
52 Performance.AddCustomMonitor("MyCategory/MyMonitor", monitorValue);
53 // Adds monitor with name "MyName" to category "Custom".
54 // Note: "MyCategory/MyMonitor" and "MyMonitor" have same name but different ids so the code is valid.
55 Performance.AddCustomMonitor("MyMonitor", monitorValue);
56
57 // Adds monitor with name "MyName" to category "Custom".
58 // Note: "MyMonitor" and "Custom/MyMonitor" have same name and same category but different ids so the code is valid.
59 Performance.AddCustomMonitor("Custom/MyMonitor", monitorValue);
60
61 // Adds monitor with name "MyCategoryOne/MyCategoryTwo/MyMonitor" to category "Custom".
62 Performance.AddCustomMonitor("MyCategoryOne/MyCategoryTwo/MyMonitor", monitorValue);
63 }
64
65 public int GetMonitorValue()
66 {
67 return GD.Randi() % 25;
68 }
69 [/csharp]
70 [/codeblocks]
71 The debugger calls the callable to get the value of custom monitor. The callable must return a zero or positive integer or floating-point number.
72 Callables are called with arguments supplied in argument array.
73 </description>
74 </method>
75 <method name="get_custom_monitor">
76 <return type="Variant" />
77 <param index="0" name="id" type="StringName" />
78 <description>
79 Returns the value of custom monitor with given [param id]. The callable is called to get the value of custom monitor. See also [method has_custom_monitor]. Prints an error if the given [param id] is absent.
80 </description>
81 </method>
82 <method name="get_custom_monitor_names">
83 <return type="StringName[]" />
84 <description>
85 Returns the names of active custom monitors in an [Array].
86 </description>
87 </method>
88 <method name="get_custom_monitor_types">
89 <return type="PackedInt32Array" />
90 <description>
91 Returns the [enum MonitorType] values of active custom monitors in an [Array].
92 </description>
93 </method>
94 <method name="get_monitor" qualifiers="const">
95 <return type="float" />
96 <param index="0" name="monitor" type="int" enum="Performance.Monitor" />
97 <description>
98 Returns the value of one of the available built-in monitors. You should provide one of the [enum Monitor] constants as the argument, like this:
99 [codeblocks]
100 [gdscript]
101 print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console.
102 [/gdscript]
103 [csharp]
104 GD.Print(Performance.GetMonitor(Performance.Monitor.TimeFps)); // Prints the FPS to the console.
105 [/csharp]
106 [/codeblocks]
107 See [method get_custom_monitor] to query custom performance monitors' values.
108 </description>
109 </method>
110 <method name="get_monitor_modification_time">
111 <return type="int" />
112 <description>
113 Returns the last tick in which custom monitor was added/removed (in microseconds since the engine started). This is set to [method Time.get_ticks_usec] when the monitor is updated.
114 </description>
115 </method>
116 <method name="has_custom_monitor">
117 <return type="bool" />
118 <param index="0" name="id" type="StringName" />
119 <description>
120 Returns [code]true[/code] if custom monitor with the given [param id] is present, [code]false[/code] otherwise.
121 </description>
122 </method>
123 <method name="remove_custom_monitor">
124 <return type="void" />
125 <param index="0" name="id" type="StringName" />
126 <description>
127 Removes the custom monitor with given [param id]. Prints an error if the given [param id] is already absent.
128 </description>
129 </method>
130 </methods>
131 <constants>
132 <constant name="TIME_FPS" value="0" enum="Monitor">
133 The number of frames rendered in the last second. This metric is only updated once per second, even if queried more often. [i]Higher is better.[/i]
134 </constant>
135 <constant name="TIME_PROCESS" value="1" enum="Monitor">
136 Time it took to complete one frame, in seconds. [i]Lower is better.[/i]
137 </constant>
138 <constant name="TIME_PHYSICS_PROCESS" value="2" enum="Monitor">
139 Time it took to complete one physics frame, in seconds. [i]Lower is better.[/i]
140 </constant>
141 <constant name="TIME_NAVIGATION_PROCESS" value="3" enum="Monitor">
142 Time it took to complete one navigation step, in seconds. This includes navigation map updates as well as agent avoidance calculations. [i]Lower is better.[/i]
143 </constant>
144 <constant name="MEMORY_STATIC" value="4" enum="Monitor">
145 Static memory currently used, in bytes. Not available in release builds. [i]Lower is better.[/i]
146 </constant>
147 <constant name="MEMORY_STATIC_MAX" value="5" enum="Monitor">
148 Available static memory. Not available in release builds. [i]Lower is better.[/i]
149 </constant>
150 <constant name="MEMORY_MESSAGE_BUFFER_MAX" value="6" enum="Monitor">
151 Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications. [i]Lower is better.[/i]
152 </constant>
153 <constant name="OBJECT_COUNT" value="7" enum="Monitor">
154 Number of objects currently instantiated (including nodes). [i]Lower is better.[/i]
155 </constant>
156 <constant name="OBJECT_RESOURCE_COUNT" value="8" enum="Monitor">
157 Number of resources currently used. [i]Lower is better.[/i]
158 </constant>
159 <constant name="OBJECT_NODE_COUNT" value="9" enum="Monitor">
160 Number of nodes currently instantiated in the scene tree. This also includes the root node. [i]Lower is better.[/i]
161 </constant>
162 <constant name="OBJECT_ORPHAN_NODE_COUNT" value="10" enum="Monitor">
163 Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree. [i]Lower is better.[/i]
164 [b]Note:[/b] This is only available in debug mode and will always return [code]0[/code] when used in a project exported in release mode.
165 </constant>
166 <constant name="RENDER_TOTAL_OBJECTS_IN_FRAME" value="11" enum="Monitor">
167 The total number of objects in the last rendered frame. This metric doesn't include culled objects (either via hiding nodes, frustum culling or occlusion culling). [i]Lower is better.[/i]
168 </constant>
169 <constant name="RENDER_TOTAL_PRIMITIVES_IN_FRAME" value="12" enum="Monitor">
170 The total number of vertices or indices rendered in the last rendered frame. This metric doesn't include primitives from culled objects (either via hiding nodes, frustum culling or occlusion culling). Due to the depth prepass and shadow passes, the number of primitives is always higher than the actual number of vertices in the scene (typically double or triple the original vertex count). [i]Lower is better.[/i]
171 </constant>
172 <constant name="RENDER_TOTAL_DRAW_CALLS_IN_FRAME" value="13" enum="Monitor">
173 The total number of draw calls performed in the last rendered frame. This metric doesn't include culled objects (either via hiding nodes, frustum culling or occlusion culling), since they do not result in draw calls. [i]Lower is better.[/i]
174 </constant>
175 <constant name="RENDER_VIDEO_MEM_USED" value="14" enum="Monitor">
176 The amount of video memory used (texture and vertex memory combined, in bytes). Since this metric also includes miscellaneous allocations, this value is always greater than the sum of [constant RENDER_TEXTURE_MEM_USED] and [constant RENDER_BUFFER_MEM_USED]. [i]Lower is better.[/i]
177 </constant>
178 <constant name="RENDER_TEXTURE_MEM_USED" value="15" enum="Monitor">
179 The amount of texture memory used (in bytes). [i]Lower is better.[/i]
180 </constant>
181 <constant name="RENDER_BUFFER_MEM_USED" value="16" enum="Monitor">
182 The amount of render buffer memory used (in bytes). [i]Lower is better.[/i]
183 </constant>
184 <constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="17" enum="Monitor">
185 Number of active [RigidBody2D] nodes in the game. [i]Lower is better.[/i]
186 </constant>
187 <constant name="PHYSICS_2D_COLLISION_PAIRS" value="18" enum="Monitor">
188 Number of collision pairs in the 2D physics engine. [i]Lower is better.[/i]
189 </constant>
190 <constant name="PHYSICS_2D_ISLAND_COUNT" value="19" enum="Monitor">
191 Number of islands in the 2D physics engine. [i]Lower is better.[/i]
192 </constant>
193 <constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="20" enum="Monitor">
194 Number of active [RigidBody3D] and [VehicleBody3D] nodes in the game. [i]Lower is better.[/i]
195 </constant>
196 <constant name="PHYSICS_3D_COLLISION_PAIRS" value="21" enum="Monitor">
197 Number of collision pairs in the 3D physics engine. [i]Lower is better.[/i]
198 </constant>
199 <constant name="PHYSICS_3D_ISLAND_COUNT" value="22" enum="Monitor">
200 Number of islands in the 3D physics engine. [i]Lower is better.[/i]
201 </constant>
202 <constant name="AUDIO_OUTPUT_LATENCY" value="23" enum="Monitor">
203 Output latency of the [AudioServer]. Equivalent to calling [method AudioServer.get_output_latency], it is not recommended to call this every frame.
204 </constant>
205 <constant name="NAVIGATION_ACTIVE_MAPS" value="24" enum="Monitor">
206 Number of active navigation maps in [NavigationServer2D] and [NavigationServer3D]. This also includes the empty default navigation maps created by [World2D] and [World3D] instances.
207 </constant>
208 <constant name="NAVIGATION_REGION_COUNT" value="25" enum="Monitor">
209 Number of active navigation regions in [NavigationServer2D] and [NavigationServer3D].
210 </constant>
211 <constant name="NAVIGATION_AGENT_COUNT" value="26" enum="Monitor">
212 Number of active navigation agents processing avoidance in [NavigationServer2D] and [NavigationServer3D].
213 </constant>
214 <constant name="NAVIGATION_LINK_COUNT" value="27" enum="Monitor">
215 Number of active navigation links in [NavigationServer2D] and [NavigationServer3D].
216 </constant>
217 <constant name="NAVIGATION_POLYGON_COUNT" value="28" enum="Monitor">
218 Number of navigation mesh polygons in [NavigationServer2D] and [NavigationServer3D].
219 </constant>
220 <constant name="NAVIGATION_EDGE_COUNT" value="29" enum="Monitor">
221 Number of navigation mesh polygon edges in [NavigationServer2D] and [NavigationServer3D].
222 </constant>
223 <constant name="NAVIGATION_EDGE_MERGE_COUNT" value="30" enum="Monitor">
224 Number of navigation mesh polygon edges that were merged due to edge key overlap in [NavigationServer2D] and [NavigationServer3D].
225 </constant>
226 <constant name="NAVIGATION_EDGE_CONNECTION_COUNT" value="31" enum="Monitor">
227 Number of polygon edges that are considered connected by edge proximity [NavigationServer2D] and [NavigationServer3D].
228 </constant>
229 <constant name="NAVIGATION_EDGE_FREE_COUNT" value="32" enum="Monitor">
230 Number of navigation mesh polygon edges that could not be merged in [NavigationServer2D] and [NavigationServer3D]. The edges still may be connected by edge proximity or with links.
231 </constant>
232 <constant name="NAVIGATION_OBSTACLE_COUNT" value="33" enum="Monitor">
233 Number of active navigation obstacles in the [NavigationServer2D] and [NavigationServer3D].
234 </constant>
235 <constant name="PIPELINE_COMPILATIONS_CANVAS" value="34" enum="Monitor">
236 Number of pipeline compilations that were triggered by the 2D canvas renderer.
237 </constant>
238 <constant name="PIPELINE_COMPILATIONS_MESH" value="35" enum="Monitor">
239 Number of pipeline compilations that were triggered by loading meshes. These compilations will show up as longer loading times the first time a user runs the game and the pipeline is required.
240 </constant>
241 <constant name="PIPELINE_COMPILATIONS_SURFACE" value="36" enum="Monitor">
242 Number of pipeline compilations that were triggered by building the surface cache before rendering the scene. These compilations will show up as a stutter when loading a scene the first time a user runs the game and the pipeline is required.
243 </constant>
244 <constant name="PIPELINE_COMPILATIONS_DRAW" value="37" enum="Monitor">
245 Number of pipeline compilations that were triggered while drawing the scene. These compilations will show up as stutters during gameplay the first time a user runs the game and the pipeline is required.
246 </constant>
247 <constant name="PIPELINE_COMPILATIONS_SPECIALIZATION" value="38" enum="Monitor">
248 Number of pipeline compilations that were triggered to optimize the current scene. These compilations are done in the background and should not cause any stutters whatsoever.
249 </constant>
250 <constant name="NAVIGATION_2D_ACTIVE_MAPS" value="39" enum="Monitor">
251 Number of active navigation maps in the [NavigationServer2D]. This also includes the empty default navigation maps created by [World2D] instances.
252 </constant>
253 <constant name="NAVIGATION_2D_REGION_COUNT" value="40" enum="Monitor">
254 Number of active navigation regions in the [NavigationServer2D].
255 </constant>
256 <constant name="NAVIGATION_2D_AGENT_COUNT" value="41" enum="Monitor">
257 Number of active navigation agents processing avoidance in the [NavigationServer2D].
258 </constant>
259 <constant name="NAVIGATION_2D_LINK_COUNT" value="42" enum="Monitor">
260 Number of active navigation links in the [NavigationServer2D].
261 </constant>
262 <constant name="NAVIGATION_2D_POLYGON_COUNT" value="43" enum="Monitor">
263 Number of navigation mesh polygons in the [NavigationServer2D].
264 </constant>
265 <constant name="NAVIGATION_2D_EDGE_COUNT" value="44" enum="Monitor">
266 Number of navigation mesh polygon edges in the [NavigationServer2D].
267 </constant>
268 <constant name="NAVIGATION_2D_EDGE_MERGE_COUNT" value="45" enum="Monitor">
269 Number of navigation mesh polygon edges that were merged due to edge key overlap in the [NavigationServer2D].
270 </constant>
271 <constant name="NAVIGATION_2D_EDGE_CONNECTION_COUNT" value="46" enum="Monitor">
272 Number of polygon edges that are considered connected by edge proximity [NavigationServer2D].
273 </constant>
274 <constant name="NAVIGATION_2D_EDGE_FREE_COUNT" value="47" enum="Monitor">
275 Number of navigation mesh polygon edges that could not be merged in the [NavigationServer2D]. The edges still may be connected by edge proximity or with links.
276 </constant>
277 <constant name="NAVIGATION_2D_OBSTACLE_COUNT" value="48" enum="Monitor">
278 Number of active navigation obstacles in the [NavigationServer2D].
279 </constant>
280 <constant name="NAVIGATION_3D_ACTIVE_MAPS" value="49" enum="Monitor">
281 Number of active navigation maps in the [NavigationServer3D]. This also includes the empty default navigation maps created by [World3D] instances.
282 </constant>
283 <constant name="NAVIGATION_3D_REGION_COUNT" value="50" enum="Monitor">
284 Number of active navigation regions in the [NavigationServer3D].
285 </constant>
286 <constant name="NAVIGATION_3D_AGENT_COUNT" value="51" enum="Monitor">
287 Number of active navigation agents processing avoidance in the [NavigationServer3D].
288 </constant>
289 <constant name="NAVIGATION_3D_LINK_COUNT" value="52" enum="Monitor">
290 Number of active navigation links in the [NavigationServer3D].
291 </constant>
292 <constant name="NAVIGATION_3D_POLYGON_COUNT" value="53" enum="Monitor">
293 Number of navigation mesh polygons in the [NavigationServer3D].
294 </constant>
295 <constant name="NAVIGATION_3D_EDGE_COUNT" value="54" enum="Monitor">
296 Number of navigation mesh polygon edges in the [NavigationServer3D].
297 </constant>
298 <constant name="NAVIGATION_3D_EDGE_MERGE_COUNT" value="55" enum="Monitor">
299 Number of navigation mesh polygon edges that were merged due to edge key overlap in the [NavigationServer3D].
300 </constant>
301 <constant name="NAVIGATION_3D_EDGE_CONNECTION_COUNT" value="56" enum="Monitor">
302 Number of polygon edges that are considered connected by edge proximity [NavigationServer3D].
303 </constant>
304 <constant name="NAVIGATION_3D_EDGE_FREE_COUNT" value="57" enum="Monitor">
305 Number of navigation mesh polygon edges that could not be merged in the [NavigationServer3D]. The edges still may be connected by edge proximity or with links.
306 </constant>
307 <constant name="NAVIGATION_3D_OBSTACLE_COUNT" value="58" enum="Monitor">
308 Number of active navigation obstacles in the [NavigationServer3D].
309 </constant>
310 <constant name="MONITOR_MAX" value="59" enum="Monitor">
311 Represents the size of the [enum Monitor] enum.
312 </constant>
313 <constant name="MONITOR_TYPE_QUANTITY" value="0" enum="MonitorType">
314 Monitor output is formatted as an integer value.
315 </constant>
316 <constant name="MONITOR_TYPE_MEMORY" value="1" enum="MonitorType">
317 Monitor output is formatted as computer memory. Submitted values should represent a number of bytes.
318 </constant>
319 <constant name="MONITOR_TYPE_TIME" value="2" enum="MonitorType">
320 Monitor output is formatted as time in milliseconds. Submitted values should represent a time in seconds (not milliseconds).
321 </constant>
322 <constant name="MONITOR_TYPE_PERCENTAGE" value="3" enum="MonitorType">
323 Monitor output is formatted as a percentage. Submitted values should represent a fractional value rather than the percentage directly, e.g. [code]0.5[/code] for [code]50.00%[/code].
324 </constant>
325 </constants>
326 </class>