How to profile Visual C++, Visual C#, and Visual Basic code in Windows Store apps on a local machine

In Visual Studio, the profiling tools for Windows Store apps let you measure, evaluate, and target performance-related issues in your code. The profiler collects timing information for apps that are written using Visual C++, Visual C#, and Visual Basic by using a sampling method that collects CPU call stack information at regular intervals. Profiling report views display graphical and tabular representations of detailed, context-rich information about the performance of your app and help you navigate through the execution paths of your code and the execution cost of your functions so that you can find the best opportunities for optimization. You can collect profiling information from the start to finish of a profiling run, or you can collect performance only for those scenarios that you are interested in.

Note

This topic describes how to profile XAML and Visual C++, Visual C#, or Visual Basic code in Windows Store apps on the machine where Visual Studio is installed.

In this topic

Here’s what you’ll learn:

Quick start: the easy way to profile

Profile a release build of your app

Choose the local machine deployment target

(Optional) Configure the debug properties of the project

Profile the app

  • Collect performance data for the entire profiling run

  • Collect performance data for specific scenarios

Analyze the profiling results

Quick start: the easy way to profile

In many cases, you can collect profiling data for an app in a few steps.

However, the Visual Studio profiler does use the debug settings of the project to configure deployment of the app on the local machine. If you have changed any of the standard debug settings of your project, you should first make sure that the settings are compatible with profiling. See (Optional) Configure the debug properties of the project in this topic for more information.

Five-step profiling

  1. Profile the Release version of your app Choose Release from the Solution configuration drop-down list on the standard toolbar.

  2. Select the local machine as your deployment target. Choose Local Machine from the drop-down list next to the Start Debugging button on the Visual Studio Standard toolbar.

    Run on Local Machine

  3. Start the profiler. Choose Start Performance Analysis (Keyboard: ALT + F2 to start your app and start profiling immediately.

  4. Exercise the app. Run those parts of the application that you want to profile. Repeat key scenarios to get more accurate results.

  5. Stop profiling. In the profiling document window, choose Stop profiling (Keyboard: CTRL + ALT + F2). The profiler analyzes the data and displays the Summary view of the profiling data.

When you stop the profiling run, the profiler analyzes the data and displays the Summary view of the profiling data in a document window of the IDE. See Analyzing performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps.

Profile a release build of your app

Because release builds of your application include all of the compiler generated optimizations that your app will contain when you release it, profiling a release build provides the most accurate information about the performance of your app. To specify a release build, choose Release from the Solution configuration drop-down list on the standard toolbar.

Choose the local machine deployment target

Note

We do not recommend profiling in the simulator because the simulator can distort the performance of your app.

To run the app on the local machine, choose Local Machine from the drop-down list next to the Start Debugging button on the Visual Studio Standard toolbar.

Run on Local Machine

You can also set the host in the property pages of your app project. See Running Windows Store apps on the local machine.

(Optional) Configure the debug properties of the project

If you have changed the properties on the Debug (Visual C++) or Debugging (Visual C# and Visual Basic), you should reset them to the following values. Values marked as N/A are ignored by the profiler:

Visual C++

C++ Debug property page

Property

Value

Debugger to launch

Local Debugger

Launch Application

Yes

Allow Local Network Loopback

N/A

Debugger Type

N/A

Visual C# / Visual Basic

C++ / VB Debugging property page

Property

Value

Do not launch, but debug my code when it starts

Clear this check box

Allow Local Network Loopback

N/A

Target device

Local Machine

Remote machine

N/A

Use authentication

N/A

Uninstall and re-install my package. All information about the application state is deleted

Clear this check box

Debugger Type

N/A

Profile the app

You can collect profiling data for the entire run, or you can collect data only for specific scenarios.

Stop Profiling

Hh696631.collapse_all(en-us,VS.110).gifCollect performance data for the entire profiling run

To profile your app from the start to the end, do this:

  1. Start the profiler. Choose Start Performance Analysis (Keyboard: ALT + F2) to start your app and start profiling immediately.

  2. Exercise the app. Run those parts of the application that you want to profile. To get more accurate results, repeat scenarios in a single profiling run to collect more samples.

  3. Stop profiling. In the profiling document window, choose Stop profiling (Keyboard: CTRL + ALT + F2). The profiler analyzes the data and displays the Summary view of the profiling data.

Hh696631.collapse_all(en-us,VS.110).gifCollect performance data for specific scenarios

To profile a specific scenario in your app, do this:

  1. Start the profiler. Choose Start Performance Analysis Paused (Keyboard: CTRL + ALT + F2) to start your app with profiling suspended.

  2. Resume and suspend profiling. Just before you begin the scenario that you are interested in, choose Resume profiling in the profiling document window. Exercise the scenario, and then choose Pause profiling to suspend data collection. You can suspend and resume profiling as often as you choose.

  3. Stop profiling. In the profiling document window, choose Stop profiling (Keyboard: CTRL + ALT + F2).

Analyze the profiling results

When you stop the profiling run, the profiler analyzes the data and displays the Summary view of the profiling data in a document window of the IDE. See Analyzing performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps.

See Also

Concepts

Analyzing the performance of Windows Store apps

How to profile Visual C++, Visual C#, and Visual Basic code in Windows Store apps on a remote device

How to profile JavaScript code in Windows Store apps on a local machine

How to profile JavaScript code in Windows Store apps on a remote device

Analyzing performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps