Performance tools in Visual Studio Team Edition allow developers to measure, evaluate and target performance-related issues in their code.
These tools are fully integrated into the integrated development environment (IDE) to provide a seamless and approachable user experience. The performance tools support two methods of profiling: Sampling and Instrumentation.
The process of profiling an application is straightforward. You can begin by creating a new performance session. In Microsoft Visual Studio Team Edition for Software Developers, you can use the Performance Session Wizard to create a new performance session. After a performance session ends, data gathered during profiling is saved in a .vsp file. You can view the .vsp file inside the IDE. There are six views available to help detect performance issues from the data gathered. Performance tools can be easily used from the command-line. This allows users the flexibility of running these tools from the command-line or using them to automate tasks that use script.
At specified intervals, the Sampling method collects information about the functions that are executing in your application. After you finish a profiling run, the Summary view of the profiling data appears in the main Visual Studio window. The Summary view shows the most active function call tree, called the Hot Path, where most of the work in the application was performed, this view also lists which functions were performing the most individual work, and provides a timeline graph you can use to focus on specific segments of the sampling session.
These tools are fully integrated into the integrated development environment (IDE) to provide a seamless and approachable user experience. The performance tools support two methods of profiling: Sampling and Instrumentation.
The process of profiling an application is straightforward. You can begin by creating a new performance session. In Microsoft Visual Studio Team Edition for Software Developers, you can use the Performance Session Wizard to create a new performance session. After a performance session ends, data gathered during profiling is saved in a .vsp file. You can view the .vsp file inside the IDE. There are six views available to help detect performance issues from the data gathered. Performance tools can be easily used from the command-line. This allows users the flexibility of running these tools from the command-line or using them to automate tasks that use script.
Performance Session
When you use the Performance Profiler, you create a Performance Session, which contains the configuration data for collecting performance information and the results of one or more profiling runs. After you create a performance session it appears in the Performance Explorer window.- The name of the profiling session.
- The Targets folder shows the projects or binaries that are profiled in the session.
- The Reports folder contains the profiling data files from one or more collection runs. You can click a file name and select views of the performance information such as functions calls, memory allocations, and details of specific functions. Each views are displayed in the main Visual Studio window.
Sampling Method
Sampling is a statistical profiling method that shows you the functions that are doing most of the user mode work in the application. Sampling is a good place to start to look for areas to speed up your application.At specified intervals, the Sampling method collects information about the functions that are executing in your application. After you finish a profiling run, the Summary view of the profiling data appears in the main Visual Studio window. The Summary view shows the most active function call tree, called the Hot Path, where most of the work in the application was performed, this view also lists which functions were performing the most individual work, and provides a timeline graph you can use to focus on specific segments of the sampling session.
Prerequisites for profiling
These are a few things that you can do before you start profiling to make sure that you do not encounter unnecessary problems.a. Run as administrator
If you are not an administrator on the computer that you are using, you should run Visual Studio as an administrator to make sure that you have the permissions that are necessary for some of the features in the profiling tools. To do this, click the Start button, locate the Visual Studio application icon, right-click the icon, and then click Run as administrator.b. Set the active build configuration to Release
Debug builds insert additional diagnostic code into your application and do not include optimizations that the compiler performs in release builds. Profiling the release version of your application provides more accurate data about the performance of your application. To change the active configuration, on the Build menu click Configuration Manager and in the dialog box, under Active solution configurations, select Release.
c. Get Windows symbols files
If you profile code that calls Windows functions, you should make sure that you have the most current .pdb files. Without these files your report views will list Windows function names that are cryptic and difficult to understand.
Create Performance Session for ASP.NET Applications
You can use the Performance Wizard to create a performance session for an ASP.NET application. A performance session can be created with or without opening a project in Visual Studio.
To create a performance session for ASP.NET application
- Open the ASP.NET Web project in Visual Studio.
- On the Tools menu, point to Performance Tools, and then click Performance Wizard.
- In the Which of the following available targets would you like to profile? drop-down list, make sure the current project is selected, and then click Next.
- Choose Sampling or Instrumentation to specify a profiling method, and then click Next.
- Click Finish.
A performance session is created for the ASP.NET application.
To create a performance session for ASP.NET application manually
- On the Tools menu, point to Performance Tools, and then click Performance Wizard.
- From the Which of the following available targets would you like to profile? drop-down list, select Profile an ASP.NET application, and then click Next.
- In the What local URL or Path will run your web application box, enter the URL, and then click Next.
Important: For a server (IIS) based Web site, enter a URL such as, http://localhost/MySite/default.aspx. This causes the ASP.NET application on the local computer at the application root of MySite to be profiled, and the page default.aspx on that site to be launched in Internet Explorer to start the session. - For a file based Web site, enter a path such as, c:\WebSites\MySite\default.aspx. This causes the ASP.NET application located at c:\webSites\MySite to be profiled and the page http://localhost:nnnn/MySite/default.aspx to be launched in Internet Explorer to start the session.
- Choose Sampling or Instrumentation to specify a profiling method, and then click Next.
- Click Finish.
Profile a Web Site or Web Application Using the Performance Wizard
You can use the Performance Wizard to collect performance data for an ASP.NET Web application. You can profile a Web application that is open in Visual Studio, or you can profile an ASP.NET Web site that is located on your local computer and not open in the Visual Studio IDE.
Depending on User Access Permissions settings that an administrator has made available, an individual user might or might not have security permission to create a profiler session on the computer that hosts the ASP.NET process. The following examples illustrate possible differences among users:
- Some users may access advanced profiling features when the Administrator has set the driver and service to start.
- Domain users may access sample profiling only.
- Some users my deny access to profiling to all other users.
To profile a Web site project
- Open the ASP.NET Web project in Visual Studio Premium or Visual Studio Ultimate.
- On the Analyze menu, click Launch Performance Wizard.
- On the first page of the wizard, select a profiling method, and then click Next. Note that the concurrency visualizer profiling method is not available for web applications.
- In the Which application would you like to target for profiling? drop-down list, make sure that the current project is selected, and then click Next.
- On the third page of the wizard, you can choose to add tier interaction profiling (TIP) data, data from the JavaScript running in the Web pages, or both.
- To collect tier interaction, select the Enable Tier Interaction Profiling check box.
- To collect data from the JavaScript running in the Web pages, select the Profile JavaScript check box.
- On the third page of the wizard, you can choose to add tier interaction profiling (TIP) data, data from the JavaScript running in the Web pages, or both.
- On the fourth page of the wizard, click Finish
- A performance session is created for the ASP.NET application, and the Web site is started in the browser. Exercise the functionality that you want to profile, and then close the browser
To profile a Web site without opening a project in Visual Studio
- Open Visual Studio Premium or Visual Studio Ultimate.
- On the Analyze menu, click Launch Performance Wizard.
- On the first page of the wizard, select a profiling method, and then click Next.
- On the second page of the wizard, select the Profile an ASP.NET or JavaScript application option, and then click Next.
- In the What URL or Path will run your web application box on the third page of the wizard, enter the URL to the application home page, and then click Next.
- For a server (IIS) based Web site, type a URL such as http://localhost/MySite/default.aspx. This causes the ASP.NET application on the local computer at the application root of MySite to be profiled, and the page default.aspx on that site to be started in Internet Explorer to start the session.
- For a file based Web site, type a path such as file///c:\WebSites\MySite\default.aspx. This causes the ASP.NET application located at c:\webSites\MySite to be profiled and the page http://localhost:nnnn/MySite/default.aspx to be started in Internet Explorer to start the session.
- For external sites that you wish to collect JavaScript data on, type the URL, for example http://www.contoso.com.
- On the third page of the wizard, you can choose to add tier interaction profiling (TIP) data, data from the JavaScript running in the Web pages, or both.
- To collect tier interaction, select the Enable Tier Interaction Profiling check box.
- To collect data from the JavaScript running in the Web pages, select the Profile JavaScript check box.
- Click Next.
- On the fourth page of the wizard, click Finish.
- A performance session is created for the ASP.NET application, and the Web site is started in the browser. Exercise the functionality that you want to profile, and then close the browser.
About Author:
Dhairut
Dholakia is technology lover and is important part of Systems Plus
technology Think Tank. He works in Systems Plus Pvt. Ltd. and actively contributes
to technology. He can be contacted at: dhairut.d@spluspl.com
Good article. Although would like to see the reports / summary views that are generated.
ReplyDelete