performance.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*************************************************************************/
  2. /* performance.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 _process_time;
  40. float _physics_process_time;
  41. public:
  42. enum Monitor {
  43. TIME_FPS,
  44. TIME_PROCESS,
  45. TIME_PHYSICS_PROCESS,
  46. MEMORY_STATIC,
  47. MEMORY_DYNAMIC,
  48. MEMORY_STATIC_MAX,
  49. MEMORY_DYNAMIC_MAX,
  50. MEMORY_MESSAGE_BUFFER_MAX,
  51. OBJECT_COUNT,
  52. OBJECT_RESOURCE_COUNT,
  53. OBJECT_NODE_COUNT,
  54. RENDER_OBJECTS_IN_FRAME,
  55. RENDER_VERTICES_IN_FRAME,
  56. RENDER_MATERIAL_CHANGES_IN_FRAME,
  57. RENDER_SHADER_CHANGES_IN_FRAME,
  58. RENDER_SURFACE_CHANGES_IN_FRAME,
  59. RENDER_DRAW_CALLS_IN_FRAME,
  60. RENDER_VIDEO_MEM_USED,
  61. RENDER_TEXTURE_MEM_USED,
  62. RENDER_VERTEX_MEM_USED,
  63. RENDER_USAGE_VIDEO_MEM_TOTAL,
  64. PHYSICS_2D_ACTIVE_OBJECTS,
  65. PHYSICS_2D_COLLISION_PAIRS,
  66. PHYSICS_2D_ISLAND_COUNT,
  67. PHYSICS_3D_ACTIVE_OBJECTS,
  68. PHYSICS_3D_COLLISION_PAIRS,
  69. PHYSICS_3D_ISLAND_COUNT,
  70. //physics
  71. AUDIO_OUTPUT_LATENCY,
  72. MONITOR_MAX
  73. };
  74. enum MonitorType {
  75. MONITOR_TYPE_QUANTITY,
  76. MONITOR_TYPE_MEMORY,
  77. MONITOR_TYPE_TIME
  78. };
  79. float get_monitor(Monitor p_monitor) const;
  80. String get_monitor_name(Monitor p_monitor) const;
  81. MonitorType get_monitor_type(Monitor p_monitor) const;
  82. void set_process_time(float p_pt);
  83. void set_physics_process_time(float p_pt);
  84. static Performance *get_singleton() { return singleton; }
  85. Performance();
  86. };
  87. VARIANT_ENUM_CAST(Performance::Monitor);
  88. #endif // PERFORMANCE_H