Use visual Studio to find app performance bottlenecks
Last updated on : 2014-05-05
Read the Prerequisites :
Environment : Windows 8.1 64bit in English, Visual Studio 2013 professional Update1 English version
Body
Assuming that performance optimizations are taken into account throughout the development of the application, the development efficiency is very low, so we need to analyze the existing code with the Profiler tool, where is the bottleneck of performance? The focus is then optimized to improve the input-to-output ratio of the product, and the Visual Studio 2013 Professional profile tool has four features. Ordinary C + + programs use only [CPU sampling] and [instrument] two functions, where [CPU sampling] is the recommended option for analyzing C + + program performance.
Take a few seconds to execute the completed C + + language Windows Console project as an example. Select the main menu [Analyze]->[performance and Diagnostics] to open the [Performancewizard] form. There are four options. Select CPU sampling (recommended). The call time of the measured function. The wizard has three steps and finally clicks [Finish] to start the profiling until the end of the program execution. The profile tool generates the sample Profiling report.
Hot Path column.
Elapsedinclusive time, Function takes
Elapsed Exclusive time. is the inclusive time minus the execution times of the child functions
Let's say you want to know how many invocations of each function can select [instrumentation] in the [Performance Wizard], because it's going to insert a measured code before and after each function, so it takes a lot longer to execute the program and analyze the report. At the end of the instrumentation Profiling report is generated, compared to the sample profilingreport is just more information about the number of function calls. So not recommended.
How do I find the most time-spent function?
Summary view, Functionswith Most individual the work bar lists the most time-consuming five functions, directly click on the function name in the list, switch to [function Details]view, the following is the Initsample function [ Functiondetails] View screenshot:
The three tiles represent the [1] caller [2] of the current function [3] being called. The dark blue background shows the percentage of time that contains the child function call (Inclusive times), and the light blue display function body (which does not contain child functions) is the percentage of the time that it occupies (Exclusive times). Click the following [Caller/callee] to go to the [Caller/callee] view, through the caller and callee list. See the number of times each function was called, and the percentage of time spent.
You can switch to the [Functions] view to see all the functions. Let these functions be sorted according to the amount of time consumed. Find the most time-consuming function you want.
Search for a specified function by name
Switch to functions (or modules) view, [ctrl]+[f] shortcut popup Find form Enter the name of the function you are looking for, specify a lookup range of [current Document], and press [Enter] to find the function. Double-click the function name to switch to the functions Details view of the function. To find a function of a module, it is best to find a function under a Modules in this view under the [Modules] view.
Find the specified function based on the number of calls
In the [Functions] view, you can click a column name. The list of functions is sorted according to the size value of the property of the column, and the function Details view can be switched to the function after it has been found.
Lookup based on function call order
How do you know the approximate location of the hotspot and switch to the [call Tree] view. When the root node is found, right-click the pop-up menu to select [Set root]. This allows you to do so without looking at the other branches, assuming that you want to reset the root node and select [Reset Root] in the pop-up menu.
According to number Ofcalls (call count) and elapsed tiime (time cost) step-by-step expansion of the node, until the function to be changed, right-click popup menu selection [View source] can go to the specific source code, [Show Function Details] When you switch to the [functiondetails] view of the current function, the upper-right corner of the blue box shows the percentage of the total time of the current function (Inclusive times), and the blue box can be left-clicked to switch to the function Details view of the specified functions. Click Caller/callee below the three box to see more specific callers. The callee information.
How to analyze a program with very long execution times
When the profile is executed, it is possible to select [Stopprofiling], end the analysis and generate the instrumentation (or sampling) Profiling report, which appears by default in summary view.
Refer to the Summary view to mark the time period for analysis on the graph. Right-click the [Filter Profiling Data by Selection] key to the popup menu.
References
"Find application bottlenecks with Visual Studio Profiler"
Http://msdn.microsoft.com/en-us/magazine/cc337887.aspx
Use visual Studio to find app performance bottlenecks