@@ -55,12 +55,13 @@ Performance *Performance::singleton = nullptr;
55
55
56
56
void Performance::_bind_methods () {
57
57
ClassDB::bind_method (D_METHOD (" get_monitor" , " monitor" ), &Performance::get_monitor);
58
- ClassDB::bind_method (D_METHOD (" add_custom_monitor" , " id" , " callable" , " arguments" ), &Performance::add_custom_monitor, DEFVAL (Array ()));
58
+ ClassDB::bind_method (D_METHOD (" add_custom_monitor" , " id" , " callable" , " arguments" , " type " ), &Performance::add_custom_monitor, DEFVAL (Array ()), DEFVAL (MONITOR_TYPE_QUANTITY ));
59
59
ClassDB::bind_method (D_METHOD (" remove_custom_monitor" , " id" ), &Performance::remove_custom_monitor);
60
60
ClassDB::bind_method (D_METHOD (" has_custom_monitor" , " id" ), &Performance::has_custom_monitor);
61
61
ClassDB::bind_method (D_METHOD (" get_custom_monitor" , " id" ), &Performance::get_custom_monitor);
62
62
ClassDB::bind_method (D_METHOD (" get_monitor_modification_time" ), &Performance::get_monitor_modification_time);
63
63
ClassDB::bind_method (D_METHOD (" get_custom_monitor_names" ), &Performance::get_custom_monitor_names);
64
+ ClassDB::bind_method (D_METHOD (" get_custom_monitor_types" ), &Performance::get_custom_monitor_types);
64
65
65
66
BIND_ENUM_CONSTANT (TIME_FPS);
66
67
BIND_ENUM_CONSTANT (TIME_PROCESS);
@@ -130,6 +131,11 @@ void Performance::_bind_methods() {
130
131
BIND_ENUM_CONSTANT (NAVIGATION_3D_OBSTACLE_COUNT);
131
132
#endif // NAVIGATION_3D_DISABLED
132
133
BIND_ENUM_CONSTANT (MONITOR_MAX);
134
+
135
+ BIND_ENUM_CONSTANT (MONITOR_TYPE_QUANTITY);
136
+ BIND_ENUM_CONSTANT (MONITOR_TYPE_MEMORY);
137
+ BIND_ENUM_CONSTANT (MONITOR_TYPE_TIME);
138
+ BIND_ENUM_CONSTANT (MONITOR_TYPE_PERCENTAGE);
133
139
}
134
140
135
141
int Performance::_get_node_count () const {
@@ -522,9 +528,9 @@ void Performance::set_navigation_process_time(double p_pt) {
522
528
_navigation_process_time = p_pt;
523
529
}
524
530
525
- void Performance::add_custom_monitor (const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args) {
531
+ void Performance::add_custom_monitor (const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args, MonitorType p_type = MONITOR_TYPE_QUANTITY ) {
526
532
ERR_FAIL_COND_MSG (has_custom_monitor (p_id), " Custom monitor with id '" + String (p_id) + " ' already exists." );
527
- _monitor_map.insert (p_id, MonitorCall (p_callable, p_args));
533
+ _monitor_map.insert (p_id, MonitorCall (p_type, p_callable, p_args));
528
534
_monitor_modification_time = OS::get_singleton ()->get_ticks_usec ();
529
535
}
530
536
@@ -561,6 +567,20 @@ TypedArray<StringName> Performance::get_custom_monitor_names() {
561
567
return return_array;
562
568
}
563
569
570
+ TypedArray<int > Performance::get_custom_monitor_types () {
571
+ if (!_monitor_map.size ()) {
572
+ return TypedArray<int >();
573
+ }
574
+ TypedArray<int > return_array;
575
+ return_array.resize (_monitor_map.size ());
576
+ int index = 0 ;
577
+ for (KeyValue<StringName, MonitorCall> i : _monitor_map) {
578
+ return_array.set (index, (int )i.value .get_monitor_type ());
579
+ index++;
580
+ }
581
+ return return_array;
582
+ }
583
+
564
584
uint64_t Performance::get_monitor_modification_time () {
565
585
return _monitor_modification_time;
566
586
}
@@ -573,7 +593,8 @@ Performance::Performance() {
573
593
singleton = this ;
574
594
}
575
595
576
- Performance::MonitorCall::MonitorCall (Callable p_callable, Vector<Variant> p_arguments) {
596
+ Performance::MonitorCall::MonitorCall (Performance::MonitorType p_type, Callable p_callable, Vector<Variant> p_arguments) {
597
+ _type = p_type;
577
598
_callable = p_callable;
578
599
_arguments = p_arguments;
579
600
}
@@ -598,3 +619,7 @@ Variant Performance::MonitorCall::call(bool &r_error, String &r_error_message) {
598
619
}
599
620
return return_value;
600
621
}
622
+
623
+ Performance::MonitorType Performance::MonitorCall::get_monitor_type () {
624
+ return _type;
625
+ }
0 commit comments