How to: Capture and Analyze Performance Data Using Windows Phone Performance Analysis
March 22, 2012
You can use the Windows Phone Performance Analysis tool to improve the performance of your Windows Phone applications. You collect sample performance data in a profiling session and then view and analyze the data. You have the option of analyzing the execution performance or the memory usage of the application in a single profiling session. This topic describes how to capture execution or memory usage data and analyze it using the Performance Analysis tool.
The first step in profiling your application is to capture performance data while using your application. The captured data is stored in a performance log file with a .sap extension. After you create a log file for your application, the analyzer displays detailed information about your application that you can use to make performance improvements.
To capture performance data
-
In Visual Studio, open a Windows Phone project that targets Windows Phone OS 7.1.
-
Build the project.
For optimal profiling results, you should create a release build. For more information, see How to: Build and Deploy a Windows Phone Application Using Visual Studio.
-
On the Standard toolbar, select the target device.
For optimal profiling results, target a Windows Phone device instead of Windows Phone Emulator.
-
On the Debug menu, select Start Windows Phone Performance Analysis. If you targeting Windows Phone OS 7.0, this menu option will be disabled.
Tip:
If you are using Visual Studio Premium or Ultimate, make sure you select Start Windows Phone Performance Analysis and not Start Performance Analysis.
A blank performance log (.sap file) displays on a tab in Visual Studio. The .sap file is named automatically using a combination of the project name and a date and time stamp. All log files for a project are stored with the project unless you delete them.
The performance log initially displays settings that enable you to select the performance options you want to analyze.
Note:
If you do not specify a release build or do not deploy the application to a device, you will see a warning below the settings.
The following image shows an empty performance log and the settings.
-
In the settings, select the Execution option to analyze the performance of drawing visual items and method calls in the code.
-or-
Select the Memory option to analyze object allocation and the use of textures in the application.
Typically you should choose Execution unless you know you have a memory issue with your application.
-
Optionally, you can click Advanced Settings to display more options for analyzing your application such as whether to collect cache details, whether to collect detailed performance counters and how deep in the stack to collect memory allocations for. Select any additional settings you would like for the profiling session.
-
When you have finished making your selections, click Launch Application to start the profiling session. Your application will launch to the specified target.
-
Use and navigate through your application like a typical user would. If there are performance problems you have previously observed in your application, such as uneven scrolling or an unresponsive user interface, make sure and use those features of your application during the profiling session. You may want to use a timer and make note of when you exercise the problem areas of your application so you can analyze these later in the performance log. The following image shows a profiling session in progress.
-
When you have finished interacting with the application, stop the profiling session by clicking or tapping the Back button, which causes the application to exit. You can also stop the profiling session by switching to Visual Studio, selecting the tab that contains the performance log (.sap file), and then clicking Stop Profiling.
Note:
You should always stop a profiling session by exiting the application using the Back button or clicking Stop Profiling. Stopping a profiling session by disconnecting the device or emulator can cause sampling errors.
To analyze performance data
-
In Solution Explorer, double-click a performance log (.sap) file to open it in Visual Studio. If you just finished a profiling session, this performance log file should already be open in Visual Studio.
The graph for the profiling session displays in Visual Studio.
-
Use the graph to observe the frame rate for the application during the profiling session as well as its CPU usage, memory usage, storyboard, image loads and garbage collection events. For more information about the Graphs section, see Windows Phone Performance Analysis.
-
To identify specific issues with the application, select a region in the graphed timeline. Detailed information for the selected portion of the timeline will display in the performance analysis summary below the graph.
The following image shows an example of a selected region and the results in the performance analysis section.
-
In the performance analysis table, you will see three types of entries identified by the following icons.
-
Information items -
Warning items -
Error items
-
-
For each
Information,
Warning, and
Error entry you should follow the instructions in the Observation Summary column to further investigate the source of the information, warning, or error item. These instructions will walk you through what selections to make from the Performance Warnings navigation toolbar and what to look for in the resulting view. You can click Performance Warnings in the navigation toolbar to hide the additional views and return to the performance analysis summary. The following image shows the navigation toolbar expanded to show the CPU Usage view.
For more information about common performance issues, see How to: Identify and Fix Common Performance Issues Using Windows Phone Performance Analysis.