| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/object/class_db.h" |
| 34 |
#include "core/templates/hash_map.h" |
| 35 |
|
| 36 |
#define PERF_WARN_OFFLINE_FUNCTION |
| 37 |
#define PERF_WARN_PROCESS_SYNC |
| 38 |
|
| 39 |
template <typename T> |
| 40 |
class TypedArray; |
| 41 |
|
| 42 |
class Performance : public Object { |
| 43 |
GDCLASS(Performance, Object); |
| 44 |
|
| 45 |
static Performance *singleton; |
| 46 |
static void _bind_methods(); |
| 47 |
|
| 48 |
#ifndef DISABLE_DEPRECATED |
| 49 |
void _add_custom_monitor_bind_compat_110433(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args); |
| 50 |
static void _bind_compatibility_methods(); |
| 51 |
#endif |
| 52 |
|
| 53 |
int _get_node_count() const; |
| 54 |
int _get_orphan_node_count() const; |
| 55 |
|
| 56 |
double _process_time; |
| 57 |
double _physics_process_time; |
| 58 |
double _navigation_process_time; |
| 59 |
|
| 60 |
public: |
| 61 |
enum Monitor { |
| 62 |
TIME_FPS, |
| 63 |
TIME_PROCESS, |
| 64 |
TIME_PHYSICS_PROCESS, |
| 65 |
TIME_NAVIGATION_PROCESS, |
| 66 |
MEMORY_STATIC, |
| 67 |
MEMORY_STATIC_MAX, |
| 68 |
MEMORY_MESSAGE_BUFFER_MAX, |
| 69 |
OBJECT_COUNT, |
| 70 |
OBJECT_RESOURCE_COUNT, |
| 71 |
OBJECT_NODE_COUNT, |
| 72 |
OBJECT_ORPHAN_NODE_COUNT, |
| 73 |
RENDER_TOTAL_OBJECTS_IN_FRAME, |
| 74 |
RENDER_TOTAL_PRIMITIVES_IN_FRAME, |
| 75 |
RENDER_TOTAL_DRAW_CALLS_IN_FRAME, |
| 76 |
RENDER_VIDEO_MEM_USED, |
| 77 |
RENDER_TEXTURE_MEM_USED, |
| 78 |
RENDER_BUFFER_MEM_USED, |
| 79 |
PHYSICS_2D_ACTIVE_OBJECTS, |
| 80 |
PHYSICS_2D_COLLISION_PAIRS, |
| 81 |
PHYSICS_2D_ISLAND_COUNT, |
| 82 |
PHYSICS_3D_ACTIVE_OBJECTS, |
| 83 |
PHYSICS_3D_COLLISION_PAIRS, |
| 84 |
PHYSICS_3D_ISLAND_COUNT, |
| 85 |
AUDIO_OUTPUT_LATENCY, |
| 86 |
|
| 87 |
NAVIGATION_ACTIVE_MAPS, |
| 88 |
NAVIGATION_REGION_COUNT, |
| 89 |
NAVIGATION_AGENT_COUNT, |
| 90 |
NAVIGATION_LINK_COUNT, |
| 91 |
NAVIGATION_POLYGON_COUNT, |
| 92 |
NAVIGATION_EDGE_COUNT, |
| 93 |
NAVIGATION_EDGE_MERGE_COUNT, |
| 94 |
NAVIGATION_EDGE_CONNECTION_COUNT, |
| 95 |
NAVIGATION_EDGE_FREE_COUNT, |
| 96 |
NAVIGATION_OBSTACLE_COUNT, |
| 97 |
PIPELINE_COMPILATIONS_CANVAS, |
| 98 |
PIPELINE_COMPILATIONS_MESH, |
| 99 |
PIPELINE_COMPILATIONS_SURFACE, |
| 100 |
PIPELINE_COMPILATIONS_DRAW, |
| 101 |
PIPELINE_COMPILATIONS_SPECIALIZATION, |
| 102 |
NAVIGATION_2D_ACTIVE_MAPS, |
| 103 |
NAVIGATION_2D_REGION_COUNT, |
| 104 |
NAVIGATION_2D_AGENT_COUNT, |
| 105 |
NAVIGATION_2D_LINK_COUNT, |
| 106 |
NAVIGATION_2D_POLYGON_COUNT, |
| 107 |
NAVIGATION_2D_EDGE_COUNT, |
| 108 |
NAVIGATION_2D_EDGE_MERGE_COUNT, |
| 109 |
NAVIGATION_2D_EDGE_CONNECTION_COUNT, |
| 110 |
NAVIGATION_2D_EDGE_FREE_COUNT, |
| 111 |
NAVIGATION_2D_OBSTACLE_COUNT, |
| 112 |
#ifndef _3D_DISABLED |
| 113 |
NAVIGATION_3D_ACTIVE_MAPS, |
| 114 |
NAVIGATION_3D_REGION_COUNT, |
| 115 |
NAVIGATION_3D_AGENT_COUNT, |
| 116 |
NAVIGATION_3D_LINK_COUNT, |
| 117 |
NAVIGATION_3D_POLYGON_COUNT, |
| 118 |
NAVIGATION_3D_EDGE_COUNT, |
| 119 |
NAVIGATION_3D_EDGE_MERGE_COUNT, |
| 120 |
NAVIGATION_3D_EDGE_CONNECTION_COUNT, |
| 121 |
NAVIGATION_3D_EDGE_FREE_COUNT, |
| 122 |
NAVIGATION_3D_OBSTACLE_COUNT, |
| 123 |
#endif |
| 124 |
MONITOR_MAX |
| 125 |
}; |
| 126 |
|
| 127 |
enum MonitorType { |
| 128 |
MONITOR_TYPE_QUANTITY, |
| 129 |
MONITOR_TYPE_MEMORY, |
| 130 |
MONITOR_TYPE_TIME, |
| 131 |
MONITOR_TYPE_PERCENTAGE, |
| 132 |
}; |
| 133 |
|
| 134 |
double get_monitor(Monitor p_monitor) const; |
| 135 |
String get_monitor_name(Monitor p_monitor) const; |
| 136 |
|
| 137 |
MonitorType get_monitor_type(Monitor p_monitor) const; |
| 138 |
|
| 139 |
void set_process_time(double p_pt); |
| 140 |
void set_physics_process_time(double p_pt); |
| 141 |
void set_navigation_process_time(double p_pt); |
| 142 |
|
| 143 |
void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args, MonitorType p_type = MONITOR_TYPE_QUANTITY); |
| 144 |
void remove_custom_monitor(const StringName &p_id); |
| 145 |
bool has_custom_monitor(const StringName &p_id); |
| 146 |
Variant get_custom_monitor(const StringName &p_id); |
| 147 |
TypedArray<StringName> get_custom_monitor_names(); |
| 148 |
Vector<int> get_custom_monitor_types(); |
| 149 |
|
| 150 |
uint64_t get_monitor_modification_time(); |
| 151 |
|
| 152 |
static Performance *get_singleton() { return singleton; } |
| 153 |
|
| 154 |
Performance(); |
| 155 |
|
| 156 |
private: |
| 157 |
class MonitorCall { |
| 158 |
MonitorType _type = MONITOR_TYPE_QUANTITY; |
| 159 |
Callable _callable; |
| 160 |
Vector<Variant> _arguments; |
| 161 |
|
| 162 |
public: |
| 163 |
MonitorCall(MonitorType p_type, const Callable &p_callable, const Vector<Variant> &p_arguments); |
| 164 |
MonitorCall(); |
| 165 |
Variant call(bool &r_error, String &r_error_message); |
| 166 |
inline MonitorType get_monitor_type() const { return _type; } |
| 167 |
}; |
| 168 |
|
| 169 |
HashMap<StringName, MonitorCall> _monitor_map; |
| 170 |
uint64_t _monitor_modification_time; |
| 171 |
}; |
| 172 |
|
| 173 |
VARIANT_ENUM_CAST(Performance::Monitor); |
| 174 |
VARIANT_ENUM_CAST(Performance::MonitorType); |