godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

Profiler Time only show two decimals #45140

Closed HeartoLazor closed 3 years ago

HeartoLazor commented 3 years ago

Godot version: Godot 3.2.3 stable

Issue description: There was a regresión in profile time information, in older godot versions show five decimals in time column, now show two, which isn't useful considering a frame at 60 fps is 0.016 ms, worse in 144 fps setups (0.00694 ms), so most of the frame times are below the two decimal range and the editor shows 0.00 for everything. x5yYIYq Looking at source code, the culprit is this line: https://github.com/godotengine/godot/blob/3.2.3-stable/editor/script_editor_debugger.cpp#L877 label = rtos(value * 1000).pad_decimals(2) + " ms"; Where someone hardcoded the decimal number. My proposal to fix this issue is expose the decimal number in editor settings using 5 as default value.

Steps to reproduce: Open profiler and profile a scene, then look at the time values.

Calinou commented 3 years ago

Profiler time is now shown in milliseconds rather than seconds. I only changed the formatting, not the amount of information displayed. Therefore, you now see just as much information as before, as time was previously shown in seconds.

Instead of having 0.00015 seconds, you now have 0.15 milliseconds which is exactly the same.

useful considering a frame at 60 fps is 0.016 ms

A frame at 60 FPS is ~16.6 milliseconds, not ~0.016 milliseconds :slightly_smiling_face:

HeartoLazor commented 3 years ago

Oh understood, still as you see in my screenshot for example shows 0.15 ms for all scripts and the methods 0.00, So I can't evaluate the performance weight of each method. I'm assuming they are in the 0.00x range. A third decimal can be useful in this case, so the point about a configuration variable for decimals still is valid, maybe with default value of 2 instead of 5.

Calinou commented 3 years ago

I'm assuming they are in the 0.00x range. A third decimal can be useful in this case, so the point about a configuration variable for decimals still is valid, maybe with default value of 2 instead of 5.

It's more likely that the profiler simply isn't able to trace at this level of precision. I doubt the GDScript profiler was designed for high levels of accuracy, since that would impact performance too much. (This is a design decision you have to make when writing a profiler.)

It's not like a method taking less than 0.01 ms to run will impact your game's performance meaningfully anyway…

HeartoLazor commented 3 years ago

Update: I increased the limit of profiled methods to 512 (as is dangerously hardcoded limit to this value) and now the profiler show more coherent values: image So this means the methods between the method limit aren't ordered by frame time, so the algorithm can cut methods causing bottlenecks using the default values. Worse the script function total time seems to be using only the frame time between the method limit. @Calinou Should I create a new issue for this problem? Idk what should be the best solution, maybe default to a higher value the limit?