Visual Studio--profiler Analysis Program performance

Source: Internet
Author: User
Tags time interval

For the latest documentation for Visual Studio RC, see https://docs.microsoft.com/zh-cn/visualstudio/.

You can use the Visual Studio profiling tool to analyze performance issues in your application. This article shows how to use sampled data.

sampling is a statistical learning method that you can show: in the application, that part does most of the user model work. Sampling is a good way to find out where to speed up your program.

At a specified time interval, the sampling method collects information about the functions that are executed in the application. When you have completed the run of an analysis, the Summary view of the analyzed data shows the most active function, called hot Path, and most of the work in the application is executed. The view also lists the most unique tasks for performing functions, and provides a timeline chart that you can use to consider only a subset of the sample results.

If the sampling method does not give you the results you want, other analytical tool collection methods can provide different information that may be helpful to you, see https://msdn.microsoft.com/en-us/library/ms182374.aspx for more information on these methods.


Tips:

If your profile code calls Windows functions, you should make sure that you have the latest PDB files. Without these files, your report view will list the names of Windows functions, which are often cryptic and difficult to understand. For more information on how to make sure you have the files you need, please refer to: https://msdn.microsoft.com/en-us/library/89axdy6y.aspx.


Create and run a performance session

In order to get the data you need to analyze, you must first create a performance session and then run the session, and the Performance Wizard will give you both a balance.

If you are not analyzing a Windows desktop application or an ASP. NET application, you must use one of the other profiling tools, see https://msdn.microsoft.com/en-us/library/mt210448.aspx.

Step one: In order to create and run a performance session:

1. Open the solution in VS and set the configuration to release. (Find "solution Configuration" in the toolbar and change the debug to release)

Note: If you are not the administrator of the computer you are using, you should run vs as an administrator when you use the profiler. (Right-click the run icon for VS and click "Run as Administrator")

2. From the Debug menu, click Performance Analyzer

3. Click the Performance Wizard option and click Start

4. Click the "CPU sampling" option, click "Finish"

5. Your application starts and the profiler starts collecting data

6. Operating functions may include performance issues

7. As you usually do, close the application


When you run the application, a summary view of the parsed data appears in the main window of VS, and the new session icon appears in the Performance Probe window.

Step two: Analyze sampled data

When you complete a performance session, the summary view of the analysis report appears in the main window of vs.

We recommend that you start by examining hot Path to analyze your data, the list of functions is the majority of the work done, and finally analyze the other functions by using the summary schedule. You can view the warnings in the configuration suggestions and errors list .

Please note that the sampling method may not give you the information you need. For example, sampling is collected only when the application is executing user-mode code. Therefore, some functions, such as input and output operations, cannot be sampled. The analysis tool provides a collection of methods that enable you to focus on analyzing some important data. For more information on other methods, see https://msdn.microsoft.com/enus/library/ms182374.aspx.

Each label area in the diagram corresponds to a process step:


In order to analyze sampled data:

1. In the summary view , hot path shows the branch with the highest containment sample in your application. This is the most active execution path when data is collected. A high containment value can indicate that the algorithm generates a call tree that can be optimized. Find the shortest path in the function in the code, note that the path can include system functionality and system functionality in the external module.


(1) Inclusive Samples: Shows how much work is done by the function and which functions call it. The high containment count points to the most expensive whole of functions.

(2) Exclusive Samples: Shows how much work is done by the code in the body of the function, not including the function that called it. The high exclusive count represents the performance bottleneck of the function itself.

2. Click the function name to display a functional detail View of the profiling data. The feature Details View provides a graphical view selection of the profiling data, showing all functions called by the function and all functions that call the function.

The size of the block that invokes the function and the called function represents the relative frequency of the function call.

You can click the name of the calling function or called function to display the function details of the selected function.

The functional details window of the lower plane shows the function code itself. If you examine the code to find an opportunity to optimize its performance, click the name of the original file to open the file in the VS editor.

3. Continue your analysis by selecting Summary in the View drop-down list to return to the summary view . Then check the function in Functions Doing the most individual work. This list shows the functions with the highest exclusive samples. The code of the function body in these functions performs important work and you can optimize it. To further analyze a particular feature, click the detail View of the function to display it.

Continuing your analysis, you can re-analyze a section of the analyzed data by using the timeline in the summary view to show you the hot path and functions Doing Most individual work of the selected part, Focus on a small spike in the timeline, which may reveal expensive call trees and functions that may not be displayed throughout the analysis run.

To re-parse a small segment, select a small segment in the timeline, and then click Filter by Selection.


4. The parser also uses a set of rules to suggest ways to improve the profiling run and to identify possible performance issues. If a problem is found, a warning window appears in the Error List .

On the View menu, click Error List, and then open the Error List window.

In order to see this error function, a warning feature is presented in the Details view , double-click the warning.

In order to view the details warning, right-click the error, and then clicking Show Error Help .


Step three: Modify the code and rerun the session

When you find that one or more features can be optimized, you can run the analysis repeatedly and compare the differences in the data to get the performance of your changed application.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.