class_performance.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Performance.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Performance:
  6. Performance
  7. ===========
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Exposes performance-related data.
  10. Description
  11. -----------
  12. 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 :ref:`get_monitor<class_Performance_method_get_monitor>` method of this class, you can access this data from your code.
  13. **Note:** A few of these monitors are only available in debug mode and will always return 0 when used in a release build.
  14. **Note:** Many of these monitors are not updated in real-time, so there may be a short delay between changes.
  15. Methods
  16. -------
  17. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`get_monitor<class_Performance_method_get_monitor>` **(** :ref:`Monitor<enum_Performance_Monitor>` monitor **)** |const| |
  19. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------+
  20. Enumerations
  21. ------------
  22. .. _enum_Performance_Monitor:
  23. .. _class_Performance_constant_TIME_FPS:
  24. .. _class_Performance_constant_TIME_PROCESS:
  25. .. _class_Performance_constant_TIME_PHYSICS_PROCESS:
  26. .. _class_Performance_constant_MEMORY_STATIC:
  27. .. _class_Performance_constant_MEMORY_DYNAMIC:
  28. .. _class_Performance_constant_MEMORY_STATIC_MAX:
  29. .. _class_Performance_constant_MEMORY_DYNAMIC_MAX:
  30. .. _class_Performance_constant_MEMORY_MESSAGE_BUFFER_MAX:
  31. .. _class_Performance_constant_OBJECT_COUNT:
  32. .. _class_Performance_constant_OBJECT_RESOURCE_COUNT:
  33. .. _class_Performance_constant_OBJECT_NODE_COUNT:
  34. .. _class_Performance_constant_OBJECT_ORPHAN_NODE_COUNT:
  35. .. _class_Performance_constant_RENDER_OBJECTS_IN_FRAME:
  36. .. _class_Performance_constant_RENDER_VERTICES_IN_FRAME:
  37. .. _class_Performance_constant_RENDER_MATERIAL_CHANGES_IN_FRAME:
  38. .. _class_Performance_constant_RENDER_SHADER_CHANGES_IN_FRAME:
  39. .. _class_Performance_constant_RENDER_SURFACE_CHANGES_IN_FRAME:
  40. .. _class_Performance_constant_RENDER_DRAW_CALLS_IN_FRAME:
  41. .. _class_Performance_constant_RENDER_2D_ITEMS_IN_FRAME:
  42. .. _class_Performance_constant_RENDER_2D_DRAW_CALLS_IN_FRAME:
  43. .. _class_Performance_constant_RENDER_VIDEO_MEM_USED:
  44. .. _class_Performance_constant_RENDER_TEXTURE_MEM_USED:
  45. .. _class_Performance_constant_RENDER_VERTEX_MEM_USED:
  46. .. _class_Performance_constant_RENDER_USAGE_VIDEO_MEM_TOTAL:
  47. .. _class_Performance_constant_PHYSICS_2D_ACTIVE_OBJECTS:
  48. .. _class_Performance_constant_PHYSICS_2D_COLLISION_PAIRS:
  49. .. _class_Performance_constant_PHYSICS_2D_ISLAND_COUNT:
  50. .. _class_Performance_constant_PHYSICS_3D_ACTIVE_OBJECTS:
  51. .. _class_Performance_constant_PHYSICS_3D_COLLISION_PAIRS:
  52. .. _class_Performance_constant_PHYSICS_3D_ISLAND_COUNT:
  53. .. _class_Performance_constant_AUDIO_OUTPUT_LATENCY:
  54. .. _class_Performance_constant_MONITOR_MAX:
  55. enum **Monitor**:
  56. - **TIME_FPS** = **0** --- Number of frames per second.
  57. - **TIME_PROCESS** = **1** --- Time it took to complete one frame, in seconds.
  58. - **TIME_PHYSICS_PROCESS** = **2** --- Time it took to complete one physics frame, in seconds.
  59. - **MEMORY_STATIC** = **3** --- Static memory currently used, in bytes. Not available in release builds.
  60. - **MEMORY_DYNAMIC** = **4** --- Dynamic memory currently used, in bytes. Not available in release builds.
  61. - **MEMORY_STATIC_MAX** = **5** --- Available static memory. Not available in release builds.
  62. - **MEMORY_DYNAMIC_MAX** = **6** --- Available dynamic memory. Not available in release builds.
  63. - **MEMORY_MESSAGE_BUFFER_MAX** = **7** --- Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
  64. - **OBJECT_COUNT** = **8** --- Number of objects currently instanced (including nodes).
  65. - **OBJECT_RESOURCE_COUNT** = **9** --- Number of resources currently used.
  66. - **OBJECT_NODE_COUNT** = **10** --- Number of nodes currently instanced in the scene tree. This also includes the root node.
  67. - **OBJECT_ORPHAN_NODE_COUNT** = **11** --- Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree.
  68. - **RENDER_OBJECTS_IN_FRAME** = **12** --- 3D objects drawn per frame.
  69. - **RENDER_VERTICES_IN_FRAME** = **13** --- Vertices drawn per frame. 3D only.
  70. - **RENDER_MATERIAL_CHANGES_IN_FRAME** = **14** --- Material changes per frame. 3D only.
  71. - **RENDER_SHADER_CHANGES_IN_FRAME** = **15** --- Shader changes per frame. 3D only.
  72. - **RENDER_SURFACE_CHANGES_IN_FRAME** = **16** --- Render surface changes per frame. 3D only.
  73. - **RENDER_DRAW_CALLS_IN_FRAME** = **17** --- Draw calls per frame. 3D only.
  74. - **RENDER_2D_ITEMS_IN_FRAME** = **18** --- Items or joined items drawn per frame.
  75. - **RENDER_2D_DRAW_CALLS_IN_FRAME** = **19** --- Draw calls per frame.
  76. - **RENDER_VIDEO_MEM_USED** = **20** --- The amount of video memory used, i.e. texture and vertex memory combined.
  77. - **RENDER_TEXTURE_MEM_USED** = **21** --- The amount of texture memory used.
  78. - **RENDER_VERTEX_MEM_USED** = **22** --- The amount of vertex memory used.
  79. - **RENDER_USAGE_VIDEO_MEM_TOTAL** = **23** --- Unimplemented in the GLES2 and GLES3 rendering backends, always returns 0.
  80. - **PHYSICS_2D_ACTIVE_OBJECTS** = **24** --- Number of active :ref:`RigidBody2D<class_RigidBody2D>` nodes in the game.
  81. - **PHYSICS_2D_COLLISION_PAIRS** = **25** --- Number of collision pairs in the 2D physics engine.
  82. - **PHYSICS_2D_ISLAND_COUNT** = **26** --- Number of islands in the 2D physics engine.
  83. - **PHYSICS_3D_ACTIVE_OBJECTS** = **27** --- Number of active :ref:`RigidBody<class_RigidBody>` and :ref:`VehicleBody<class_VehicleBody>` nodes in the game.
  84. - **PHYSICS_3D_COLLISION_PAIRS** = **28** --- Number of collision pairs in the 3D physics engine.
  85. - **PHYSICS_3D_ISLAND_COUNT** = **29** --- Number of islands in the 3D physics engine.
  86. - **AUDIO_OUTPUT_LATENCY** = **30** --- Output latency of the :ref:`AudioServer<class_AudioServer>`.
  87. - **MONITOR_MAX** = **31** --- Represents the size of the :ref:`Monitor<enum_Performance_Monitor>` enum.
  88. Method Descriptions
  89. -------------------
  90. .. _class_Performance_method_get_monitor:
  91. - :ref:`float<class_float>` **get_monitor** **(** :ref:`Monitor<enum_Performance_Monitor>` monitor **)** |const|
  92. Returns the value of one of the available monitors. You should provide one of the :ref:`Monitor<enum_Performance_Monitor>` constants as the argument, like this:
  93. ::
  94. print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console
  95. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  96. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  97. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`