Performance

package
v0.0.0-...-535787f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

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 Monitor tab in the editor's Debugger panel. By using the GetMonitor method of this class, you can access this data from your code.

You can add custom monitors using the AddCustomMonitor method. Custom monitors are available in Monitor tab in the editor's Debugger panel together with built-in monitors.

Note: Some of the built-in monitors are only available in debug mode and will always return 0 when used in a project exported in release mode.

Note: 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.

Note: Custom monitors do not support negative values. Negative values are clamped to 0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCustomMonitor

func AddCustomMonitor(id string, callable Callable.Function, arguments []any)

Adds a custom monitor with the name 'id'. You can specify the category of the monitor using slash delimiters in 'id' (for example: "Game/NumberOfNPCs"). If there is more than one slash delimiter, then the default category is used. The default category is "Custom". Prints an error if given 'id' is already present.

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.

Callables are called with arguments supplied in argument array.

func AddCustomMonitorOptions

func AddCustomMonitorOptions(id string, callable Callable.Function, arguments []any)

Adds a custom monitor with the name 'id'. You can specify the category of the monitor using slash delimiters in 'id' (for example: "Game/NumberOfNPCs"). If there is more than one slash delimiter, then the default category is used. The default category is "Custom". Prints an error if given 'id' is already present.

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.

Callables are called with arguments supplied in argument array.

func Advanced

func Advanced() class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

func GetCustomMonitor

func GetCustomMonitor(id string) any

Returns the value of custom monitor with given 'id'. The callable is called to get the value of custom monitor. See also HasCustomMonitor. Prints an error if the given 'id' is absent.

func GetCustomMonitorNames

func GetCustomMonitorNames() []string

Returns the names of active custom monitors in an slice.

func GetMonitor

func GetMonitor(monitor Monitor) Float.X

Returns the value of one of the available built-in monitors. You should provide one of the Monitor constants as the argument, like this:

See GetCustomMonitor to query custom performance monitors' values.

func GetMonitorModificationTime

func GetMonitorModificationTime() int

Returns the last tick in which custom monitor was added/removed (in microseconds since the engine started). This is set to graphics.gd/classdb/Time.GetTicksUsec when the monitor is updated.

func HasCustomMonitor

func HasCustomMonitor(id string) bool

Returns true if custom monitor with the given 'id' is present, false otherwise.

func RemoveCustomMonitor

func RemoveCustomMonitor(id string)

Removes the custom monitor with given 'id'. Prints an error if the given 'id' is already absent.

Types

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Performance

Instance of the class with convieniently typed arguments and results.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Monitor

type Monitor int //gd:Performance.Monitor
const (
	// The number of frames rendered in the last second. This metric is only updated once per second, even if queried more often. Higher is better.
	TimeFps Monitor = 0
	// Time it took to complete one frame, in seconds. Lower is better.
	TimeProcess Monitor = 1
	// Time it took to complete one physics frame, in seconds. Lower is better.
	TimePhysicsProcess Monitor = 2
	// Time it took to complete one navigation step, in seconds. This includes navigation map updates as well as agent avoidance calculations. Lower is better.
	TimeNavigationProcess Monitor = 3
	// Static memory currently used, in bytes. Not available in release builds. Lower is better.
	MemoryStatic Monitor = 4
	// Available static memory. Not available in release builds. Lower is better.
	MemoryStaticMax Monitor = 5
	// Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications. Lower is better.
	MemoryMessageBufferMax Monitor = 6
	// Number of objects currently instantiated (including nodes). Lower is better.
	ObjectCount Monitor = 7
	// Number of resources currently used. Lower is better.
	ObjectResourceCount Monitor = 8
	// Number of nodes currently instantiated in the scene tree. This also includes the root node. Lower is better.
	ObjectNodeCount Monitor = 9
	// Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree. Lower is better.
	ObjectOrphanNodeCount Monitor = 10
	// 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). Lower is better.
	RenderTotalObjectsInFrame Monitor = 11
	// 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). Lower is better.
	RenderTotalPrimitivesInFrame Monitor = 12
	// 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. Lower is better.
	RenderTotalDrawCallsInFrame Monitor = 13
	// 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 [RenderTextureMemUsed] and [RenderBufferMemUsed]. Lower is better.
	RenderVideoMemUsed Monitor = 14
	// The amount of texture memory used (in bytes). Lower is better.
	RenderTextureMemUsed Monitor = 15
	// The amount of render buffer memory used (in bytes). Lower is better.
	RenderBufferMemUsed Monitor = 16
	// Number of active [graphics.gd/classdb/RigidBody2D] nodes in the game. Lower is better.
	Physics2dActiveObjects Monitor = 17
	// Number of collision pairs in the 2D physics engine. Lower is better.
	Physics2dCollisionPairs Monitor = 18
	// Number of islands in the 2D physics engine. Lower is better.
	Physics2dIslandCount Monitor = 19
	// Number of active [graphics.gd/classdb/RigidBody3D] and [graphics.gd/classdb/VehicleBody3D] nodes in the game. Lower is better.
	Physics3dActiveObjects Monitor = 20
	// Number of collision pairs in the 3D physics engine. Lower is better.
	Physics3dCollisionPairs Monitor = 21
	// Number of islands in the 3D physics engine. Lower is better.
	Physics3dIslandCount Monitor = 22
	// Output latency of the [graphics.gd/classdb/AudioServer]. Equivalent to calling [graphics.gd/classdb/AudioServer.GetOutputLatency], it is not recommended to call this every frame.
	AudioOutputLatency Monitor = 23
	// Number of active navigation maps in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D]. This also includes the two empty default navigation maps created by World2D and World3D.
	NavigationActiveMaps Monitor = 24
	// Number of active navigation regions in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationRegionCount Monitor = 25
	// Number of active navigation agents processing avoidance in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationAgentCount Monitor = 26
	// Number of active navigation links in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationLinkCount Monitor = 27
	// Number of navigation mesh polygons in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationPolygonCount Monitor = 28
	// Number of navigation mesh polygon edges in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationEdgeCount Monitor = 29
	// Number of navigation mesh polygon edges that were merged due to edge key overlap in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationEdgeMergeCount Monitor = 30
	// Number of polygon edges that are considered connected by edge proximity [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationEdgeConnectionCount Monitor = 31
	// Number of navigation mesh polygon edges that could not be merged in [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D]. The edges still may be connected by edge proximity or with links.
	NavigationEdgeFreeCount Monitor = 32
	// Number of active navigation obstacles in the [graphics.gd/classdb/NavigationServer2D] and [graphics.gd/classdb/NavigationServer3D].
	NavigationObstacleCount Monitor = 33
	// Number of pipeline compilations that were triggered by the 2D canvas renderer.
	PipelineCompilationsCanvas Monitor = 34
	// 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.
	PipelineCompilationsMesh Monitor = 35
	// 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.
	PipelineCompilationsSurface Monitor = 36
	// 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.
	PipelineCompilationsDraw Monitor = 37
	// 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.
	PipelineCompilationsSpecialization Monitor = 38
	// Number of active navigation maps in the [graphics.gd/classdb/NavigationServer2D]. This also includes the two empty default navigation maps created by World2D.
	Navigation2dActiveMaps Monitor = 39
	// Number of active navigation regions in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dRegionCount Monitor = 40
	// Number of active navigation agents processing avoidance in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dAgentCount Monitor = 41
	// Number of active navigation links in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dLinkCount Monitor = 42
	// Number of navigation mesh polygons in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dPolygonCount Monitor = 43
	// Number of navigation mesh polygon edges in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dEdgeCount Monitor = 44
	// Number of navigation mesh polygon edges that were merged due to edge key overlap in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dEdgeMergeCount Monitor = 45
	// Number of polygon edges that are considered connected by edge proximity [graphics.gd/classdb/NavigationServer2D].
	Navigation2dEdgeConnectionCount Monitor = 46
	// Number of navigation mesh polygon edges that could not be merged in the [graphics.gd/classdb/NavigationServer2D]. The edges still may be connected by edge proximity or with links.
	Navigation2dEdgeFreeCount Monitor = 47
	// Number of active navigation obstacles in the [graphics.gd/classdb/NavigationServer2D].
	Navigation2dObstacleCount Monitor = 48
	// Number of active navigation maps in the [graphics.gd/classdb/NavigationServer3D]. This also includes the two empty default navigation maps created by World3D.
	Navigation3dActiveMaps Monitor = 49
	// Number of active navigation regions in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dRegionCount Monitor = 50
	// Number of active navigation agents processing avoidance in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dAgentCount Monitor = 51
	// Number of active navigation links in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dLinkCount Monitor = 52
	// Number of navigation mesh polygons in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dPolygonCount Monitor = 53
	// Number of navigation mesh polygon edges in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dEdgeCount Monitor = 54
	// Number of navigation mesh polygon edges that were merged due to edge key overlap in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dEdgeMergeCount Monitor = 55
	// Number of polygon edges that are considered connected by edge proximity [graphics.gd/classdb/NavigationServer3D].
	Navigation3dEdgeConnectionCount Monitor = 56
	// Number of navigation mesh polygon edges that could not be merged in the [graphics.gd/classdb/NavigationServer3D]. The edges still may be connected by edge proximity or with links.
	Navigation3dEdgeFreeCount Monitor = 57
	// Number of active navigation obstacles in the [graphics.gd/classdb/NavigationServer3D].
	Navigation3dObstacleCount Monitor = 58
	// Represents the size of the [Monitor] enum.
	MonitorMax Monitor = 59
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL