Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Discussion of chess software programming and technical issues.

Moderator: Ras

Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by Henk »

If you don't watch out you start believing some code is expensive while it is not. But percentage of cpu time might often be displayed on wrong source code line. So confusing. Don't understand why they are doing that. Are they blind or am I blind. Or visual studio so complex that they can't do good testing. O wait maybe they are using me as a tester.

Terrible did rewriting of certain code parts for nothing.
JoAnnP38
Posts: 253
Joined: Mon Aug 26, 2019 4:34 pm
Location: Clearwater, Florida USA
Full name: JoAnn Peeler

Re: Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by JoAnnP38 »

Thanks for the heads up! I have been using dotTrace as my profiler, but the most recent version no longer seems to give me per line performance. It could be user-error, but I was thinking about dropping back to the VS profiler.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by chrisw »

Henk wrote: Mon Jan 09, 2023 12:48 pm If you don't watch out you start believing some code is expensive while it is not. But percentage of cpu time might often be displayed on wrong source code line. So confusing. Don't understand why they are doing that. Are they blind or am I blind. Or visual studio so complex that they can't do good testing. O wait maybe they are using me as a tester.

Terrible did rewriting of certain code parts for nothing.
If you’re profiling optimised code, the profiler can’t necessarily define exactly which code line the assembly is executing.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by Henk »

Ok. So they can fix it with a warning. "Warning: You are using optimized code. Do you still want to view the percentages?". Or something.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by chrisw »

Henk wrote: Tue Jan 10, 2023 7:34 pm Ok. So they can fix it with a warning. "Warning: You are using optimized code. Do you still want to view the percentages?". Or something.
But, the purpose of profile performance is presumably to find places to make the code faster, it really only makes sense to profile the optimised version.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Visual studio community 2022 version 17.4.3 Performance profiler giving percentages at wrong source code line

Post by dangi12012 »

Use compiler explorer and see what your function compiles into.

You will see that in release builds your lines and the assembly don't map to each other. Stuff gets blended, removed, reordered with other lines and functions etc. so that's why working at the "performance per line" in visualstudio is not the way to go for advanced microoptimisations.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer