www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Profiling using Visual Studio

reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
I would just like to share some knowledge about profiling an exe 
using Visual Studio, since many might already have that installed.

After you have built your executable with symbols, open VS and 
choose "Continue without code".

Then just choose open Project/Solution (Ctrl+Shift+O) and go to 
"Debug -> Performance Profiler" (Alt+F2).

You will be presented with a windows looking something like this

![Analysis](https://i.ibb.co/L96C9yk/analysis.png)

Press start and wait for the profiling to complete.

You should now have a diagsession available to inspect.

The default view is the call tree:

![Call tree](https://i.ibb.co/52V2X46/analysis3.png)

You can also view by module, caller/callee, functions and flame 
graph.

This is an example of flame graph:

![Flame graph](https://i.ibb.co/D1zZb5V/analysis4.png)

And here's an example showing that you can go into phobos as well:

![Phobos](https://i.ibb.co/3rzKyqh/analysis4.png)

Just sharing this here if someone with VS wants an easy way to 
profile with existing tools.
Oct 22 2023
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Sunday, 22 October 2023 at 13:13:55 UTC, Imperatorn wrote:
 I would just like to share some knowledge about profiling an 
 exe using Visual Studio, since many might already have that 
 installed.

 [...]
On Sunday, 22 October 2023 at 13:13:55 UTC, Imperatorn wrote: Just a clarification. "open Project/Solution (Ctrl+Shift+O)" means, you open the executable in that file dialog :)
Oct 22 2023
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Sunday, 22 October 2023 at 13:16:11 UTC, Imperatorn wrote:
 On Sunday, 22 October 2023 at 13:13:55 UTC, Imperatorn wrote:
 I would just like to share some knowledge about profiling an 
 exe using Visual Studio, since many might already have that 
 installed.

 [...]
On Sunday, 22 October 2023 at 13:13:55 UTC, Imperatorn wrote: Just a clarification. "open Project/Solution (Ctrl+Shift+O)" means, you open the executable in that file dialog :)
You can also use IntelĀ® VTune which integrates with Visual Studio as well, however, it naturally requires you to download and install it. When installed, you can navigate to here after doing the process as described for VS. ![Navigation](https://i.ibb.co/DpXWH4P/vTune.png) If you do, you can get something similar to this: ![Intel vTune](https://i.ibb.co/Fgh9pZx/vTune.png) This can be used to see if you can for example rewrite some code to complexity. For example form O(N^2) to O(T * N) or perhaps O(N log N). It can be a really useful tool
Oct 22 2023