class_performance.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Exposes performance-related data.
  13. Methods
  14. -------
  15. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`float<class_float>` | :ref:`get_monitor<class_Performance_method_get_monitor>` **(** :ref:`Monitor<enum_Performance_Monitor>` monitor **)** const |
  17. +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  18. Enumerations
  19. ------------
  20. .. _enum_Performance_Monitor:
  21. .. _class_Performance_constant_TIME_FPS:
  22. .. _class_Performance_constant_TIME_PROCESS:
  23. .. _class_Performance_constant_TIME_PHYSICS_PROCESS:
  24. .. _class_Performance_constant_MEMORY_STATIC:
  25. .. _class_Performance_constant_MEMORY_DYNAMIC:
  26. .. _class_Performance_constant_MEMORY_STATIC_MAX:
  27. .. _class_Performance_constant_MEMORY_DYNAMIC_MAX:
  28. .. _class_Performance_constant_MEMORY_MESSAGE_BUFFER_MAX:
  29. .. _class_Performance_constant_OBJECT_COUNT:
  30. .. _class_Performance_constant_OBJECT_RESOURCE_COUNT:
  31. .. _class_Performance_constant_OBJECT_NODE_COUNT:
  32. .. _class_Performance_constant_RENDER_OBJECTS_IN_FRAME:
  33. .. _class_Performance_constant_RENDER_VERTICES_IN_FRAME:
  34. .. _class_Performance_constant_RENDER_MATERIAL_CHANGES_IN_FRAME:
  35. .. _class_Performance_constant_RENDER_SHADER_CHANGES_IN_FRAME:
  36. .. _class_Performance_constant_RENDER_SURFACE_CHANGES_IN_FRAME:
  37. .. _class_Performance_constant_RENDER_DRAW_CALLS_IN_FRAME:
  38. .. _class_Performance_constant_RENDER_VIDEO_MEM_USED:
  39. .. _class_Performance_constant_RENDER_TEXTURE_MEM_USED:
  40. .. _class_Performance_constant_RENDER_VERTEX_MEM_USED:
  41. .. _class_Performance_constant_RENDER_USAGE_VIDEO_MEM_TOTAL:
  42. .. _class_Performance_constant_PHYSICS_2D_ACTIVE_OBJECTS:
  43. .. _class_Performance_constant_PHYSICS_2D_COLLISION_PAIRS:
  44. .. _class_Performance_constant_PHYSICS_2D_ISLAND_COUNT:
  45. .. _class_Performance_constant_PHYSICS_3D_ACTIVE_OBJECTS:
  46. .. _class_Performance_constant_PHYSICS_3D_COLLISION_PAIRS:
  47. .. _class_Performance_constant_PHYSICS_3D_ISLAND_COUNT:
  48. .. _class_Performance_constant_AUDIO_OUTPUT_LATENCY:
  49. .. _class_Performance_constant_MONITOR_MAX:
  50. enum **Monitor**:
  51. - **TIME_FPS** = **0** --- Number of frames per second.
  52. - **TIME_PROCESS** = **1** --- Time it took to complete one frame, in seconds.
  53. - **TIME_PHYSICS_PROCESS** = **2** --- Time it took to complete one physics frame, in seconds.
  54. - **MEMORY_STATIC** = **3** --- Static memory currently used, in bytes. Not available in release builds.
  55. - **MEMORY_DYNAMIC** = **4** --- Dynamic memory currently used, in bytes. Not available in release builds.
  56. - **MEMORY_STATIC_MAX** = **5** --- Available static memory. Not available in release builds.
  57. - **MEMORY_DYNAMIC_MAX** = **6** --- Available dynamic memory. Not available in release builds.
  58. - **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.
  59. - **OBJECT_COUNT** = **8** --- Number of objects currently instanced (including nodes).
  60. - **OBJECT_RESOURCE_COUNT** = **9** --- Number of resources currently used.
  61. - **OBJECT_NODE_COUNT** = **10** --- Number of nodes currently instanced. This also includes the root node, as well as any nodes not in the scene tree.
  62. - **RENDER_OBJECTS_IN_FRAME** = **11** --- 3D objects drawn per frame.
  63. - **RENDER_VERTICES_IN_FRAME** = **12** --- Vertices drawn per frame. 3D only.
  64. - **RENDER_MATERIAL_CHANGES_IN_FRAME** = **13** --- Material changes per frame. 3D only
  65. - **RENDER_SHADER_CHANGES_IN_FRAME** = **14** --- Shader changes per frame. 3D only.
  66. - **RENDER_SURFACE_CHANGES_IN_FRAME** = **15** --- Render surface changes per frame. 3D only.
  67. - **RENDER_DRAW_CALLS_IN_FRAME** = **16** --- Draw calls per frame. 3D only.
  68. - **RENDER_VIDEO_MEM_USED** = **17** --- The amount of video memory used, i.e. texture and vertex memory combined.
  69. - **RENDER_TEXTURE_MEM_USED** = **18** --- The amount of texture memory used.
  70. - **RENDER_VERTEX_MEM_USED** = **19** --- The amount of vertex memory used.
  71. - **RENDER_USAGE_VIDEO_MEM_TOTAL** = **20** --- Unimplemented in the GLES2 and GLES3 rendering backends, always returns 0.
  72. - **PHYSICS_2D_ACTIVE_OBJECTS** = **21** --- Number of active :ref:`RigidBody2D<class_RigidBody2D>` nodes in the game.
  73. - **PHYSICS_2D_COLLISION_PAIRS** = **22** --- Number of collision pairs in the 2D physics engine.
  74. - **PHYSICS_2D_ISLAND_COUNT** = **23** --- Number of islands in the 2D physics engine.
  75. - **PHYSICS_3D_ACTIVE_OBJECTS** = **24** --- Number of active :ref:`RigidBody<class_RigidBody>` and :ref:`VehicleBody<class_VehicleBody>` nodes in the game.
  76. - **PHYSICS_3D_COLLISION_PAIRS** = **25** --- Number of collision pairs in the 3D physics engine.
  77. - **PHYSICS_3D_ISLAND_COUNT** = **26** --- Number of islands in the 3D physics engine.
  78. - **AUDIO_OUTPUT_LATENCY** = **27** --- Output latency of the :ref:`AudioServer<class_AudioServer>`.
  79. - **MONITOR_MAX** = **28** --- Represents the size of the :ref:`Monitor<enum_Performance_Monitor>` enum.
  80. Description
  81. -----------
  82. 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. Note that a few of these monitors are only available in debug mode and will always return 0 when used in a release build.
  83. Many of these monitors are not updated in real-time, so there may be a short delay between changes.
  84. Method Descriptions
  85. -------------------
  86. .. _class_Performance_method_get_monitor:
  87. - :ref:`float<class_float>` **get_monitor** **(** :ref:`Monitor<enum_Performance_Monitor>` monitor **)** const
  88. 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:
  89. ::
  90. print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console