performance.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* performance.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef PERFORMANCE_H
  31. #define PERFORMANCE_H
  32. #include "core/object.h"
  33. #define PERF_WARN_OFFLINE_FUNCTION
  34. #define PERF_WARN_PROCESS_SYNC
  35. class Performance : public Object {
  36. GDCLASS(Performance, Object);
  37. static Performance *singleton;
  38. static void _bind_methods();
  39. float _get_node_count() const;
  40. float _process_time;
  41. float _physics_process_time;
  42. public:
  43. enum Monitor {
  44. TIME_FPS,
  45. TIME_PROCESS,
  46. TIME_PHYSICS_PROCESS,
  47. MEMORY_STATIC,
  48. MEMORY_DYNAMIC,
  49. MEMORY_STATIC_MAX,
  50. MEMORY_DYNAMIC_MAX,
  51. MEMORY_MESSAGE_BUFFER_MAX,
  52. OBJECT_COUNT,
  53. OBJECT_RESOURCE_COUNT,
  54. OBJECT_NODE_COUNT,
  55. OBJECT_ORPHAN_NODE_COUNT,
  56. RENDER_OBJECTS_IN_FRAME,
  57. RENDER_VERTICES_IN_FRAME,
  58. RENDER_MATERIAL_CHANGES_IN_FRAME,
  59. RENDER_SHADER_CHANGES_IN_FRAME,
  60. RENDER_SURFACE_CHANGES_IN_FRAME,
  61. RENDER_DRAW_CALLS_IN_FRAME,
  62. RENDER_2D_ITEMS_IN_FRAME,
  63. RENDER_2D_DRAW_CALLS_IN_FRAME,
  64. RENDER_VIDEO_MEM_USED,
  65. RENDER_TEXTURE_MEM_USED,
  66. RENDER_VERTEX_MEM_USED,
  67. RENDER_USAGE_VIDEO_MEM_TOTAL,
  68. PHYSICS_2D_ACTIVE_OBJECTS,
  69. PHYSICS_2D_COLLISION_PAIRS,
  70. PHYSICS_2D_ISLAND_COUNT,
  71. PHYSICS_3D_ACTIVE_OBJECTS,
  72. PHYSICS_3D_COLLISION_PAIRS,
  73. PHYSICS_3D_ISLAND_COUNT,
  74. //physics
  75. AUDIO_OUTPUT_LATENCY,
  76. MONITOR_MAX
  77. };
  78. enum MonitorType {
  79. MONITOR_TYPE_QUANTITY,
  80. MONITOR_TYPE_MEMORY,
  81. MONITOR_TYPE_TIME
  82. };
  83. float get_monitor(Monitor p_monitor) const;
  84. String get_monitor_name(Monitor p_monitor) const;
  85. MonitorType get_monitor_type(Monitor p_monitor) const;
  86. void set_process_time(float p_pt);
  87. void set_physics_process_time(float p_pt);
  88. static Performance *get_singleton() { return singleton; }
  89. Performance();
  90. };
  91. VARIANT_ENUM_CAST(Performance::Monitor);
  92. #endif // PERFORMANCE_H