Profile Visual C++, Visual C#, and Visual Basic code in Windows Store apps on a local machine
In Visual Studio, the CPU Sampling profiler 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. (You can also profile managed and native components of an app that was written in JavaScript and HTML5). 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.
-
See Profile Visual C++, Visual C#, and Visual Basic code in Windows Store apps on a remote device when you want to profile an app written with XAML on a remote device.
-
See Collect JavaScript function timing data in Store apps on a local machine or Collect JavaScript function timing data in Store apps on a remote device when you want to profile Visual C++, Visual C#, and Visual Basic components of a Windows Store app written in JavaScript and HTML.
In this topic
Quick start: the easy way to profile
(Optional) Configure the debug properties of the project
Profile a running or installed app
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
Profile the Release version of your app Choose Release from the Solution configuration drop-down list on the standard toolbar.
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.
Select the local machine as your 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.
You can also set the host in the property pages of your app project. See Run Windows Store apps on the local machine.
Start the profiler. Choose Performance and Diagnostics on the Debug menu, (keyboard: ALT + F2. Choose CPU Sampling and then choose Start.
Exercise the app. Run those parts of the application that you want to profile. Repeat key scenarios to get more accurate results.
Stop profiling. In the Performance and Diagnostic document window, choose Stop collection (keyboard: CTRL + ALT + F2).
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 Analyze performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps.
(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) project property page,, you should reset them to the following values. Values marked as N/A are ignored by the profiler:
Visual C++
Property |
Value |
---|---|
Debugger to launch |
Local Debugger |
Launch Application |
Yes |
Allow Local Network Loopback |
N/A |
Debugger Type |
N/A |
Visual C# / Visual Basic
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
To profile the current Visual Studio solution or project:
Choose Performance and Diagnostics on the Debug menu, (keyboard: ALT + F2.
Choose CPU Sampling and then choose Start.
Exercise the app. Run those parts of the application that you want to profile. Repeat key scenarios to get more accurate results.
Stop profiling. In the Performance and Diagnostic document window, choose Stop collection (keyboard: CTRL + ALT + F2).
Profile a running or installed app
You can also collect profiling data for native or managed code for an app that is already running on your machine, or for an app that has been installed from the Windows Store:
Choose Performance and Diagnostics on the Debug menu, (keyboard: ALT + F2.
Choose Change Target and then choose Running App or Installed App from the Analysis Targets list.
From the Select Running App dialog box, choose the app that you want to profile.
Choose CPU Sampling and then choose Start.
Exercise the app. Run those parts of the application that you want to profile. Repeat key scenarios to get more accurate results.
Stop profiling. In the Performance and Diagnostic document window, choose Stop collection (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 Analyze performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps.
See Also
Concepts
Analyze the performance of Windows Store apps using Visual Studio diagnostic tools
Profile Visual C++, Visual C#, and Visual Basic code in Windows Store apps on a remote device
Analyze performance data for Visual C++, Visual C#, and Visual Basic code in Windows Store apps
Collect JavaScript function timing data in Store apps on a local machine
Collect JavaScript function timing data in Store apps on a remote device