Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Performance
Hérite de : Object
Expose les données relatives aux performances.
Description
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 get_monitor() method of this class, you can access this data from your code.
You can add custom monitors using the add_custom_monitor() 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.
Méthodes
void |
add_custom_monitor(id: StringName, callable: Callable, arguments: Array = [], type: MonitorType = 0) |
get_monitor(monitor: Monitor) const |
|
void |
Énumérations
enum Monitor: 🔗
Monitor TIME_FPS = 0
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.
Monitor TIME_PROCESS = 1
Le temps nécessaire pour compléter une trame, en secondes. Plus c'est bas, mieux c'est.
Monitor TIME_PHYSICS_PROCESS = 2
Le temps nécessaire pour compléter une trame physique, en secondes. Plus c'est bas, mieux c'est.
Le temps pour terminer une étape de navigation, en secondes. Cela comprend les mises à jour de la carte de navigation ainsi que les calculs d'évitement des agents. Plus c'est bas, mieux c'est.
Monitor MEMORY_STATIC = 4
La mémoire statique actuellement utilisée, en octets. N'est pas utilisable dans les versions finales. Plus c'est bas, mieux c'est.
Monitor MEMORY_STATIC_MAX = 5
La mémoire statique disponible. N'est pas utilisable dans les versions finales. Plus c'est bas, mieux c'est.
Monitor MEMORY_MESSAGE_BUFFER_MAX = 6
La plus grande quantité de mémoire que le tampon de queue de messages a utilisé, en octets. La queue de messages est utilisée pour les appels et les notifications de fonctions différées. Plus c'est bas, mieux c'est.
Monitor OBJECT_COUNT = 7
Le nombre d'objets actuellement instanciés (nœuds inclus). Plus c'est bas, mieux c'est.
Monitor OBJECT_RESOURCE_COUNT = 8
Nombre de ressources actuellement utilisées. Plus c'est bas, mieux c'est.
Monitor OBJECT_NODE_COUNT = 9
Nombre de nœuds actuellement instanciés dans l'arbre de scène. Cela inclut également le nœud racine. Plus c'est bas, mieux c'est.
Monitor OBJECT_ORPHAN_NODE_COUNT = 10
Nombre de nœuds orphelins, c'est-à-dire de nœuds qui ne sont pas parentés à un nœud de l'arbre de scène. Une valeur faible est souhaitable.
Note : Ceci est seulement disponible en mode de débogage et renvoie toujours 0 lorsqu'il est utilisé dans un projet exporté en mode release.
Monitor RENDER_TOTAL_OBJECTS_IN_FRAME = 11
Le nombre total d'objets dans la dernière trame rendue. Cette métrique n'inclut pas les objets éliminés (soit par la dissimulation des nœuds, le frustum culling ou l'occlusion culling). Plus c'est bas, mieux c'est.
Monitor RENDER_TOTAL_PRIMITIVES_IN_FRAME = 12
Le nombre total de sommets ou d'indices rendus dans la dernière trame rendue. Cette métrique n'inclut pas les primitives d'objets éliminés (soit par la dissimulation des nœuds, le frustum culling ou l'occlusion culling). À cause de la pré-passe de profondeur et des passes d'ombres, le nombre de primitives est toujours plus élevé que le nombre réel de sommets dans la scène (généralement le double ou le triple du nombre de vertex d'origine). Plus c'est bas, mieux c'est.
Monitor RENDER_TOTAL_DRAW_CALLS_IN_FRAME = 13
Le nombre total de draw calls effectués dans la dernière trame rendue. Cette métrique ne comprend pas les objets éliminés (soit par la dissimulation de nœuds, le frustum culling ou l'occlusion culling), car ils ne se traduisent pas par des draw calls. Plus c'est bas, mieux c'est.
Monitor RENDER_VIDEO_MEM_USED = 14
La quantité de mémoire vidéo utilisée (mémoire des sommets et des textures combinés, en octets). Étant donné que cette mesure comprend également des allocations diverses, cette valeur est toujours supérieure à la somme de RENDER_TEXTURE_MEM_USED et RENDER_BUFFER_MEM_USED. Plus c'est bas, mieux c'est.
Monitor RENDER_TEXTURE_MEM_USED = 15
La quantité de mémoire utilisée pour les textures (en octets). Plus c'est bas, mieux c'est.
Monitor RENDER_BUFFER_MEM_USED = 16
La quantité de mémoire de tampon de rendu utilisée (en octets). Plus c'est bas, mieux c'est.
Monitor PHYSICS_2D_ACTIVE_OBJECTS = 17
Le nombre de nœuds RigidBody2D actifs dans le jeu. Plus c'est bas, mieux c'est.
Monitor PHYSICS_2D_COLLISION_PAIRS = 18
Le nombre de paires de collision dans le moteur physique 2D. Plus c'est bas, mieux c'est.
Monitor PHYSICS_2D_ISLAND_COUNT = 19
Le nombre d'îles dans le moteur physique 2D. Plus c'est bas, mieux c'est.
Monitor PHYSICS_3D_ACTIVE_OBJECTS = 20
Le nombre de nœuds RigidBody3D et VehicleBody3D actifs dans le jeu. Plus c'est bas, mieux c'est.
Monitor PHYSICS_3D_COLLISION_PAIRS = 21
Le nombre de paires de collisions dans le moteur physique 3D. Plus c'est bas, mieux c'est.
Monitor PHYSICS_3D_ISLAND_COUNT = 22
Le nombre d'îles dans le moteur physique 3D. Plus c'est bas, mieux c'est.
Monitor AUDIO_OUTPUT_LATENCY = 23
Output latency of the AudioServer. Equivalent to calling AudioServer.get_output_latency(), it is not recommended to call this every frame.
Number of active navigation maps in NavigationServer2D and NavigationServer3D. This also includes the empty default navigation maps created by World2D and World3D instances.
Number of active navigation regions in NavigationServer2D and NavigationServer3D.
Number of active navigation agents processing avoidance in NavigationServer2D and NavigationServer3D.
Number of active navigation links in NavigationServer2D and NavigationServer3D.
Number of navigation mesh polygons in NavigationServer2D and NavigationServer3D.
Number of navigation mesh polygon edges in NavigationServer2D and NavigationServer3D.
Number of navigation mesh polygon edges that were merged due to edge key overlap in NavigationServer2D and NavigationServer3D.
Number of polygon edges that are considered connected by edge proximity NavigationServer2D and NavigationServer3D.
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.
Number of active navigation obstacles in the NavigationServer2D and NavigationServer3D.
Monitor PIPELINE_COMPILATIONS_CANVAS = 34
Number of pipeline compilations that were triggered by the 2D canvas renderer.
Monitor PIPELINE_COMPILATIONS_MESH = 35
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.
Monitor PIPELINE_COMPILATIONS_SURFACE = 36
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.
Monitor PIPELINE_COMPILATIONS_DRAW = 37
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.
Monitor PIPELINE_COMPILATIONS_SPECIALIZATION = 38
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.
Number of active navigation maps in the NavigationServer2D. This also includes the empty default navigation maps created by World2D instances.
Number of active navigation regions in the NavigationServer2D.
Number of active navigation agents processing avoidance in the NavigationServer2D.
Number of active navigation links in the NavigationServer2D.
Number of navigation mesh polygons in the NavigationServer2D.
Number of navigation mesh polygon edges in the NavigationServer2D.
Number of navigation mesh polygon edges that were merged due to edge key overlap in the NavigationServer2D.
Number of polygon edges that are considered connected by edge proximity NavigationServer2D.
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.
Number of active navigation obstacles in the NavigationServer2D.
Number of active navigation maps in the NavigationServer3D. This also includes the empty default navigation maps created by World3D instances.
Number of active navigation regions in the NavigationServer3D.
Number of active navigation agents processing avoidance in the NavigationServer3D.
Number of active navigation links in the NavigationServer3D.
Number of navigation mesh polygons in the NavigationServer3D.
Number of navigation mesh polygon edges in the NavigationServer3D.
Number of navigation mesh polygon edges that were merged due to edge key overlap in the NavigationServer3D.
Number of polygon edges that are considered connected by edge proximity NavigationServer3D.
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.
Number of active navigation obstacles in the NavigationServer3D.
Monitor MONITOR_MAX = 59
Représente la taille de l'énumération Monitor.
enum MonitorType: 🔗
MonitorType MONITOR_TYPE_QUANTITY = 0
Monitor output is formatted as an integer value.
MonitorType MONITOR_TYPE_MEMORY = 1
Monitor output is formatted as computer memory. Submitted values should represent a number of bytes.
MonitorType MONITOR_TYPE_TIME = 2
Monitor output is formatted as time in milliseconds. Submitted values should represent a time in seconds (not milliseconds).
MonitorType MONITOR_TYPE_PERCENTAGE = 3
Monitor output is formatted as a percentage. Submitted values should represent a fractional value rather than the percentage directly, e.g. 0.5 for 50.00%.
Descriptions des méthodes
void add_custom_monitor(id: StringName, callable: Callable, arguments: Array = [], type: MonitorType = 0) 🔗
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.
func _ready():
var monitor_value = Callable(self, "get_monitor_value")
# Adds monitor with name "MyName" to category "MyCategory".
Performance.add_custom_monitor("MyCategory/MyMonitor", monitor_value)
# Adds monitor with name "MyName" to category "Custom".
# Note: "MyCategory/MyMonitor" and "MyMonitor" have same name but different IDs, so the code is valid.
Performance.add_custom_monitor("MyMonitor", monitor_value)
# Adds monitor with name "MyName" to category "Custom".
# Note: "MyMonitor" and "Custom/MyMonitor" have same name and same category but different IDs, so the code is valid.
Performance.add_custom_monitor("Custom/MyMonitor", monitor_value)
# Adds monitor with name "MyCategoryOne/MyCategoryTwo/MyMonitor" to category "Custom".
Performance.add_custom_monitor("MyCategoryOne/MyCategoryTwo/MyMonitor", monitor_value)
func get_monitor_value():
return randi() % 25
public override void _Ready()
{
var monitorValue = new Callable(this, MethodName.GetMonitorValue);
// Adds monitor with name "MyName" to category "MyCategory".
Performance.AddCustomMonitor("MyCategory/MyMonitor", monitorValue);
// Adds monitor with name "MyName" to category "Custom".
// Note: "MyCategory/MyMonitor" and "MyMonitor" have same name but different ids so the code is valid.
Performance.AddCustomMonitor("MyMonitor", monitorValue);
// Adds monitor with name "MyName" to category "Custom".
// Note: "MyMonitor" and "Custom/MyMonitor" have same name and same category but different ids so the code is valid.
Performance.AddCustomMonitor("Custom/MyMonitor", monitorValue);
// Adds monitor with name "MyCategoryOne/MyCategoryTwo/MyMonitor" to category "Custom".
Performance.AddCustomMonitor("MyCategoryOne/MyCategoryTwo/MyMonitor", monitorValue);
}
public int GetMonitorValue()
{
return GD.Randi() % 25;
}
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.
Variant get_custom_monitor(id: StringName) 🔗
Returns the value of custom monitor with given id. The callable is called to get the value of custom monitor. See also has_custom_monitor(). Prints an error if the given id is absent.
Array[StringName] get_custom_monitor_names() 🔗
Returns the names of active custom monitors in an Array.
PackedInt32Array get_custom_monitor_types() 🔗
Returns the MonitorType values of active custom monitors in an Array.
float get_monitor(monitor: Monitor) const 🔗
Returns the value of one of the available built-in monitors. You should provide one of the Monitor constants as the argument, like this:
print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console.
GD.Print(Performance.GetMonitor(Performance.Monitor.TimeFps)); // Prints the FPS to the console.
See get_custom_monitor() to query custom performance monitors' values.
int get_monitor_modification_time() 🔗
Returns the last tick in which custom monitor was added/removed (in microseconds since the engine started). This is set to Time.get_ticks_usec() when the monitor is updated.
bool has_custom_monitor(id: StringName) 🔗
Returns true if custom monitor with the given id is present, false otherwise.
void remove_custom_monitor(id: StringName) 🔗
Removes the custom monitor with given id. Prints an error if the given id is already absent.