App profiling for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Windows Phone Application Analysis includes the option to profile the performance of your app while exercising its features as an ordinary user would use it.

The goal of app profiling is to help you to understand the performance of your app, and to give you actionable feedback to improve it. This information helps you to improve your app long before it reaches the end user, and to differentiate it from other apps by its stability and consistent performance. The app profiling feature aims to capture all the key metrics that are relevant from a performance perspective. The guiding principle is to help you ensure quality and performance while you’re developing your app, and not just as an afterthought.

This topic describes the workflow of an app profiling session for a managed app. For information about profiling a native app, see Profiling Direct3D apps for Windows Phone 8.

This topic contains the following sections.

Start app profiling

You can profile apps that target Windows Phone 8 or Windows Phone OS 7.1.

To start app profiling

  1. In Visual Studio, open a Windows Phone project .

  2. Build the project.

    For optimal profiling results, create a release build. For more information, see How to build an app for Windows Phone 8.

  3. You can run app analysis by using one of the following methods.

    • Press Alt-F1.

    • From the Debug menu, select Start Windows Phone Application Analysis.

Tip

Make sure you select Start Windows Phone Application Analysis and not Start Performance Analysis.

A blank performance log (.sap file) opens on a new 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 in the project folder until you delete them.

The performance log initially displays settings that enable you to select the performance options you want to analyze.

The following illustration shows the options that are available for profiling when you launch Windows Phone Performance Analysis.

![](images/JJ215908.AppAnalysis_Screen_Profiling(en-us,VS.105).png)
  1. Under Profiling, select one of the following options.

    • Select the Execution option to analyze the performance of drawing visual items and method calls in the code.

    • Select the Memory option to analyze object allocation and the use of textures in the app.

    Only the Execution option is available for Direct3D apps.

    Typically you profile Execution unless you know you that have a memory issue with your app.

  2. Optionally, expand Advanced Settings to review or change the profiling options. These settings are described under Advanced settings for execution profiling and Advanced settings for memory profiling.

  3. Then click Start Session.

    Your app starts to run on the selected emulator or device.

  4. Navigate through your app and use it as a typical user would use it. If there are performance problems you have previously observed in your app, such as uneven scrolling or an unresponsive user interface, make sure to use those features of your app during the profiling session. You may want to use a timer and make note of when you exercise the problem areas of your app so you can locate these areas later on the timeline for analysis.

    The following image shows a profiling session in progress.

Advanced settings for execution profiling

Setting

Settings group

Collect element cost for each draw operation

Visual Profiling

Collects and reports the time spent in the layout and rendering of each visual element.

This option is selected by default.

Collect cache details

Visual Profiling

Collects and reports drilldown details for analyzing composition performance.

This option is not selected by default.

Collect media (image and video) events

Visual Profiling

Collects and reports the time spent in loading media elements.

This option is not selected by default.

Collect call stack to a depth of depth once every N milliseconds

Code Sampling

The code profiler is a sampling profiler. It interrupts the computer processor at specified intervals, approximately every N milliseconds, and records the function call stack to a depth of depth stack frames.

This option is selected by default.

The available values for depth are:

  • 1

  • 2

  • 3

  • Full

The default value of depth is Full. The default value of N is 10 milliseconds.

Collect detailed performance counters

Code Sampling

Collects lightweight counters that measure specific run-time activity; for example, the number of interop calls made, or the number of functions compiled.

Important Note:
This functionality is not implemented.

This option is not selected by default.

The following screen shot shows the advanced settings for execution profiling.

Advanced settings for memory profiling

Setting

Description

Collect memory allocation stack to a depth of N

The memory profiler records the call stack for every allocation of a managed object that is made. It also records the function call stack to a depth of N stack frames.

This option is selected by default. The default value of N is 4.

Collect object references after every full GC or after every N GCs

The memory profiler computes object graphs only when one of the following conditions is true:

  • After a full garbage collection; that is, when the contents of the heap are relatively stable.

  • After at least N garbage collections; that is, at a low frequency of intrusion.

This option is selected by default. The default value of N is 5.

The following screen shot shows the advanced settings for execution profiling.

Stop app profiling

To stop app profiling

  • After you’ve gathered an adequate sampling of activities, click End Session.

Note

Always stop a profiling session by clicking Stop Profiling. Stopping a profiling session by disconnecting the device or emulator can cause sampling errors.

After you stop the monitoring session, the tool copies, parses, and analyzes the data that it has gathered. Then it displays the results.

Review and analyze the profiling results

To review and analyze the profiling results

  1. If you just finished a profiling session, the profiling results file is already open in Visual Studio. Otherwise, in Solution Explorer, double-click a performance log (.sap) file to open it in Visual Studio.

    The graph of results for the profiling session opens in Visual Studio. The profiling results include graphs and performance warnings. For more information about the graph rows and about the terms used in the graphs and warnings, see Windows Phone Application Analysis for Windows Phone 8. The results include the following sections.

    Execution profiling graphs

    The results page of execution profiling displays the following graph rows.

    • External events

    • Frame rate

    • CPU usage %

    • Application responsiveness

    • Network data transfer MBps

    • Battery consumption mAh

    • Memory usage MB

    • Storyboards

    • Image loads

    • GC events

    Memory profiling graphs

    The results page of memory profiling displays the following graph rows.

    • Memory usage MB

    • Image loads

    • GC events

  2. Review the graph to observe the frame rate for the app during the profiling session as well as its CPU usage, memory usage, storyboard, image loads and garbage collection events.

  3. To identify specific issues with the app, select a region in the timeline. When you select a portion of a graph, a detailed analysis section appears. This section provides Performance Warnings with details about the performance for the selected time period in a tabular format.

    In the Performance Warnings table, you see three types of entries identified by the following icons.

    •  Information items

    •  Warning items

    •   Error items

    The Observation Summary column contains information about the problem. You can expand the menu options to the right of the Performance Warning menu to investigate the details of a particular performance problem.

    The following image shows a section of the graph selected and the resulting display in the detailed performance analysis section.

  4. For each  Information,  Warning, and  Error entry, follow the instructions in the Observation Summary column to further investigate the cause of the information, warning, or error item. These instructions help you to make selections from the Performance Warnings navigation toolbar and to find the information you need 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.

    For more information about common performance issues, see How to identify and fix common performance issues using Windows Phone Application Analysis for Windows Phone 8.

    The following image shows the navigation toolbar expanded to show the CPU Usage view.

    The following image shows the navigation toolbar expanded to show the Frames view.

See Also

Other Resources

Profiling Direct3D apps for Windows Phone 8

How to identify and fix common performance issues using Windows Phone Application Analysis for Windows Phone 8