The profiler for Visual Studio 2010 is a self-contained performance tool that allows us to identify performance bottlenecks in the program and then continuously optimize for continuous re-testing.
Brief introduction
The profiler has two ways to test the modules that are connected to the program using the wizard launcher and later attached to the application:sampling (sampling) and Instrumentation (detection).
Sampling: Interrupts the computer processor at set intervals and collects the function call stack.
The call stack is a dynamic structure that stores information about functions that are executing on the processor. The result of this analysis method is that each function is sampled at run time, the greater the number of times represents the greater the overhead. Because there is no need to change the source code, it is possible to start directly or later attach to the program under test.
Instrumentation: At the beginning and end of the target function in the source code file, and before and after each call of the function to the other function.
The inserted code records the following information:
- The interval between this collection event and the previous collection event.
- Whether the operating system performed the operation during this interval.
For example, the operating system might read or write to a disk, or switch between the target thread and another thread in another process.
According to "Tools\options\performance Tools\" under ' Show Time values as: ' The default setting is milliseconds, I think the sampling period should be millisecond, that is, the number of samples in the report can be approximately equal to milliseconds.
Use
- To start visual Studio with an administrator
- Programs for release version
- Set the PDB path required by the program
Through the ' analyze\launch performance Wizard ... ' or ' Analyze\profiler\attach or Detach ... ' to create a new performance session (performance session) for the program under test, we mainly introduce the next sampling through Attach to Report the analysis in case of process.
After the profiler begins, something like:
When you feel that you have collected enough information to stop, click ' Stop Profiling ', similar to:
The above interface is the summary of the report, and we begin to analyze the program's performance bottlenecks.
' hot Path ' refers to a function with high sampling times, which is a performance bottleneck.
' Inclusive Samples ' refers to the total number of times the function has been sampled, and plainly, the sum of the cost of the function itself and all the child functions it invokes.
' Exclusive Samples ' refers to the number of times the function itself has been sampled, and plainly, that is, the function's own cost size, without the beginning of the child function it invokes.
- ' funcions doding most individual work ' refers to a single function with the largest cost, so its indicator is ' Exclusive
Samples ' to express.
With the introduction of the above, we can get the function of performance bottleneck, then we can get the full calling context according to call Tree.
For example, in the summary interface, click CallTree, Sort by ' Inclusive Samples ', follow the cost-size expansion method, and eventually get the overhead function context, similar to:
Of course, we can also use the above filter to choose "Modules", "Threads" and other ways to find the bottleneck of their own concern.
In addition, we can also select ' Show Just My Code ' and the appropriate CPU time period to filter on the summary interface.
Reference: Analyzing application Performance by Using Profiling Tools
The profiler in Visual Studio 2010 uses