Visual studio has a very useful tool to analyze project performance, it’s located in upper Menu under the name ANALYZE (keys shortcut – Alt+N).
This tool will show you the resource consumption percentage for each part of the code in the project.
Important – Commit your code before making any changes in order to revert the changes in case of creating new bugs
- Go to Analyze tab -> Launch Performance wizard.
- Choose the method of profiling you want to use and click Next.
I will explain using Instrumentation method of profiling
- Select the project you want to analyze and click Next.
- Mark the check-box “Launch profiling after the wizard finishes” if you want to launch the profiling after clicking finish.
There are two ways to start analyzing the project:
- “Start Performance Analysis” (keys shortcut – Alt+F2) – start the profiling and start analyze the project.
Start in this mode if you want to analyze the project from its starting point
- “Start Performance Analysis Paused” (keys shortcut – Alt+Shift+F2) – start the profiling in paused mode.
Start in this mode if you want to analyze the project from a specific point
Using the profiler
Once the Performance Analysis is running we need to stop it at some point in order to analyze its result.
We can stop the Performance Analysis in two ways:
- Close the program.
- Clicking on stop the profiling link in the visual studio.
After the profiling stopped, the Visual Studio will generate a report.
The report shows:
- CPU % usage graph
- Elapsed Inclusive Time % for most Time consuming functions
- Functions With Most Individual Work