From 90a5f23e798df8192e903fc5785e29fa093e5caa Mon Sep 17 00:00:00 2001 From: baptr <1522777+baptr@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:59:13 -0800 Subject: [PATCH] Fix editor profiler script function sort order The engine internally limits the number of functions reported back (to 16 by default). To this point, it's been sort the profiling info in *ascending* order of time spent, then trimming the list. This meant we may only see the best (fastest) functions, instead of the worst that you probably want when profiling. Now the servers_debugger sort more closely matches the local_debugger one, which worked fine. --- editor/debugger/editor_profiler.cpp | 2 +- servers/debugger/servers_debugger.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 2809b873b1..1f978bf797 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -350,7 +350,7 @@ void EditorProfiler::_update_frame() { category->set_custom_color(0, _get_color_from_signature(m.categories[i].signature)); } - for (int j = m.categories[i].items.size() - 1; j >= 0; j--) { + for (int j = 0; j < m.categories[i].items.size(); j++) { const Metric::Category::Item &it = m.categories[i].items[j]; if (it.internal == it.total && !display_internal_profiles->is_pressed() && m.categories[i].name == "Script Functions") { diff --git a/servers/debugger/servers_debugger.cpp b/servers/debugger/servers_debugger.cpp index 8da3a10ce9..06be73acc5 100644 --- a/servers/debugger/servers_debugger.cpp +++ b/servers/debugger/servers_debugger.cpp @@ -198,7 +198,7 @@ class ServersDebugger::ScriptsProfiler : public EngineProfiler { typedef ServersDebugger::ScriptFunctionInfo FunctionInfo; struct ProfileInfoSort { bool operator()(ScriptLanguage::ProfilingInfo *A, ScriptLanguage::ProfilingInfo *B) const { - return A->total_time < B->total_time; + return A->total_time > B->total_time; } }; Vector info;