diff options
author | simpu <id.simpu@gmail.com> | 2020-06-04 18:48:57 +0530 |
---|---|---|
committer | simpu <id.simpu@gmail.com> | 2020-06-29 17:20:29 +0530 |
commit | bfadb882b1d7aecd47020e177b5352638f078a75 (patch) | |
tree | bf0e00d9259ebe01da701e9a3066af3f3d3174bd /core | |
parent | 9fc65fd1f15b2ae2e26cf69c54819e7d6598fa05 (diff) |
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.
Diffstat (limited to 'core')
-rw-r--r-- | core/debugger/remote_debugger.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 62f600c5e5..9d55e1312e 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -373,6 +373,7 @@ struct RemoteDebugger::VisualProfiler { struct RemoteDebugger::PerformanceProfiler { Object *performance = nullptr; int last_perf_time = 0; + uint64_t last_monitor_modification_time = 0; void toggle(bool p_enable, const Array &p_opts) {} void add(const Array &p_data) {} @@ -386,12 +387,31 @@ struct RemoteDebugger::PerformanceProfiler { return; } last_perf_time = pt; + + Array custom_monitor_names = performance->call("get_custom_monitor_names"); + + uint64_t monitor_modification_time = performance->call("get_monitor_modification_time"); + if (monitor_modification_time > last_monitor_modification_time) { + last_monitor_modification_time = monitor_modification_time; + EngineDebugger::get_singleton()->send_message("performance:profile_names", custom_monitor_names); + } + int max = performance->get("MONITOR_MAX"); Array arr; - arr.resize(max); + arr.resize(max + custom_monitor_names.size()); for (int i = 0; i < max; i++) { arr[i] = performance->call("get_monitor", i); } + + for (int i = 0; i < custom_monitor_names.size(); i++) { + Variant monitor_value = performance->call("get_custom_monitor", custom_monitor_names[i]); + if (!monitor_value.is_num()) { + ERR_PRINT("Value of custom monitor '" + String(custom_monitor_names[i]) + "' is not a number"); + arr[i + max] = Variant(); + } + arr[i + max] = monitor_value; + } + EngineDebugger::get_singleton()->send_message("performance:profile_frame", arr); } |