Added Custom Performance Monitor and feature to read intermediate values of Monitor

Custom monitors can be added/removed/checked using `Performance.add_custom_monitor`/`Performance.remove_custom_monitor`/`Performance.has_custom_monitor`

The value can be viewed in the `Monitor` tab of Debugger.

Text before `/` is used to categorize the custom monitor.

`EditorPerformanceProfiler` class is created to separate logic from `ScriptEditorDebugger`

User can click on the graph of monitors to read the value at that point.

Graph includes intermediate base lines.
This commit is contained in:
simpu
2020-06-04 18:48:57 +05:30
parent 9fc65fd1f1
commit bfadb882b1
8 changed files with 708 additions and 242 deletions

View File

@ -32,6 +32,7 @@
#define PERFORMANCE_H
#include "core/object.h"
#include "core/ordered_hash_map.h"
#define PERF_WARN_OFFLINE_FUNCTION
#define PERF_WARN_PROCESS_SYNC
@ -47,6 +48,19 @@ class Performance : public Object {
float _process_time;
float _physics_process_time;
class MonitorCall {
Callable _callable;
Vector<Variant> _arguments;
public:
MonitorCall(Callable p_callable, Vector<Variant> p_arguments);
MonitorCall();
Variant call(bool &r_error, String &r_error_message);
};
OrderedHashMap<StringName, MonitorCall> _monitor_map;
uint64_t _monitor_modification_time;
public:
enum Monitor {
@ -95,6 +109,14 @@ public:
void set_process_time(float p_pt);
void set_physics_process_time(float p_pt);
void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args);
void remove_custom_monitor(const StringName &p_id);
bool has_custom_monitor(const StringName &p_id);
Variant get_custom_monitor(const StringName &p_id);
Array get_custom_monitor_names();
uint64_t get_monitor_modification_time();
static Performance *get_singleton() { return singleton; }
Performance();