How accurate is dmd profile? (and do I need GMD/LDC to use gprof?)

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Oct 3 21:55:29 UTC 2021


On Sun, Oct 03, 2021 at 08:31:14AM +0000, Chris Katko via Digitalmars-d wrote:
[...]
> The function that dmd's -profile reported was the biggest user of CPU
> time was a tiny little function that draws a couple background tiles.
> (<30 at worst case) As opposed to everything else being drawn, tons of
> opengl primitives, graphical text, text being converted with tons of
> writelns to console, etc.
[...]

Be aware that dmd -profile uses *16-bit counters* for tracking function
call counts; if your program is CPU-intensive and calls the same
function(s) in inner loops more than 65535 times, the counters will wrap
around and cause the profile output to be garbled.

I ran into this a couple of years ago when trying to profile some
CPU-intensive code with some non-trivial testcases, and found dmd
-profile output completely unusable because of this limitation.


T

-- 
Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen.


More information about the Digitalmars-d mailing list