Some time ago I wrote about profiling methods. Now I’m going
to continue with application performance profiling in Visual Studio and
describe main steps in using Performance Wizard.
First of all you should choose some project (application) to
analyze. It’s better to have source code
of the application, but you can use executable files as well.
Step 1. Configure and run a performance session
So let’s start. Make sure that you run your Visual Studio as
administrator. After opening project in VS choose Analyze -> Launch Performance Wizard menu item. In Performance
Wizard dialog specify profiling method to be used (read my previous post) and
choose the application to profile.
After closing the wizard your application will be started.
Then do whatever you want with your application (call functions, press buttons or
menus, etc) to load it or just wait for some time.
Step 2. Analyze application performance report
And after you close your application or after you press Stop
Profiling link in Visual Studio, profiling report will be generated and the Summary view of
the profiling report will appear in the main window in Visual Studio. On the picture bellow you can see example of
Summary profiling report (CPU Sampling was used as profiling method).
Let’s have a closer look at this report. At the top of Summary view you can see a graph
describing changes of CPU usage relative
to time. This graph helps to determine at what moments of time your application
intensively loads CPU. You can also zoom this graph or select some time
interval and filter by it.
The next very interesting part of Summary performance report
is called Hot Path. It helps to
determine the most expensive call path based on sample counts for chosen
interval of time (the whole interval of profiling by default). If you click a function
name you can see details of cost distribution for the function (the Function Details
view of the profiling data will be shown).
The Function Details
view presents a graphical view of the profiling data for the selected function,
showing all the functions that called that function and all the functions that
were called by the selected function. This view also gives you idea of what
lines of code need to be refactored to decrease CPU usage.
Except described above views of performance report you can
also use other views for deeper analysis:
Call tree view
Caller / Callee view
And of cause you can save report or export report data, or
Step 3. Revise code
of your application and rerun performance session
Analyzing different views of performance report will help
you to find places in your code to optimize. And after making changes in one or
more functions, you can repeat the profiling run and compare the data to see
the difference that your changes have made to the performance of your
I hope this information was useful for you. Read more