Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Run analysis tools from the Performance and Diagnostic page

Applies to Windows and Windows Phone

You can analyze the performance, memory use, and energy consumption of Windows Store and Windows Phone apps by using the Visual Studio profilers and diagnostic tools. The Performance and Diagnostic hub makes it easy to select and run these tools, combine multiple tools in a single diagnostic run, and manage the reports they produce. You can run the tools on most deployment targets. For Windows Phone apps, use a phone or an emulator. For Windows Store apps, use the Visual Studio computer, the simulator, or a remote PC. After you have collected the data, the diagnostic report displays timeline graphs and detail views of the data. Performance and Diagnostic report filters and settings help you to focus on the critical parts of the data.

Tools in the Performance and Diagnostic hub

The Performance and Diagnostic hub shows you the tools that you can use on particular types of apps (XAML and C#/VB/C++ or HTML and JavaScript) and the tools that you can use in a single diagnostic run.

Note Note

You must have administrator privileges to run the performance and diagnostic tools. You can run Visual Studio as an administrator, or you can choose to run the tools as an administrator when you start the diagnostic session.

  1. Open the project in Visual Studio.

  2. Set the deployment location.

    Applies to Windows Phone only

    Windows Phone apps can be deployed to a phone or one of the Visual Studio emulators.

    Applies to Windows only

    Windows Store apps can be deployed to the Visual Studio computer, the Visual Studio simulator, or on a network-connected PC or tablet.

    Note: Running a diagnostic session on a remote PC or tablet requires that the Visual Studio Remote Tools be installed and running on the remote target. See Run Windows Store apps on a remote machine from Visual Studio.

    From the debug location list on the debugger toolbar, select the deployment location for your app. Here's the list for phone apps:

    Deployment target list for Windows Phone apps

  3. Open a Performance and Diagnostic session. On the Debug menu, choose Performance and Diagnosis (Shortcut key: Alt + F2).

  4. In the Performance and Diagnostic hub, choose one or more tools to run in the session. Only the tools that are applicable to the project type and programming language are displayed. When you choose a diagnostic tool, the selections for tools that cannot be run in the same diagnostic session are disabled. Here's how your choices might look for a JavaScript app:

    Choose one or more diagnostic tools

  5. To start the diagnosis session, choose Start.

  6. Run the scenarios that you want to collect data for.

    While you are running the session, some tools display graphs of real-time data on the Performance and Diagnosis page.

    Collect data on the Performance and Diagnostic pag

  7. To end the diagnostic session, choose Stop collection.

Add user marks to identify locations in your diagnostic data | Set the startup project | Set the analysis target | Choose the tools to run in the diagnostic session | Start and stop the diagnostic session

You can add user marks to your profiling data to help identify areas in the timeline ruler.

User marks in the timeline

The mark appears as an orange triangle in the timeline at the time the method executed. The message and the time are displayed as a tooltip when you hover over the mark. If two or more user marks are close together, the marks are merged and the tooltip data is combined. You can zoom in on the timeline to separate the marks.

Note Note
  • JavaScript Function Timing reports do not display user marks.

  • Reports do not display user marks when the CPU Usage tool is the only tool that was used in a diagnostic session.

  • See the Windows SDK Sample LoggingSession Sample for more examples.

Add marks to C#, Visual Basic, C++ code

To add a user mark to C#, Visual Basic, C++ code, first create a Windows.Foundation.Diagnostics LoggingChannel object. Then insert calls to LoggingChannel.LogMessage methods at the points in your code that you want to mark. Use LoggingLevel.Information in the calls.

When the method executes, a user mark is added to the profiling data along with a message.

Notes

Adding logging channels to your code poses a couple of challenges:

Each open logging channel must have a unique name. Attempting to create a new logging channel with the same name as an open channel causes an exception.

One way to avoid duplicate names in your code is to use a static (Shared in VB) method to return a LoggingChannel with a name that is guaranteed to be unique. Here's an example that uses a Guid to provide uniqueness:

//using Windows.Foundation.Diagnostics
public static LoggingChannel GetLoggingChannel()
{
    var name = Guid.NewGuid().ToString();
    return new LoggingChannel(name);
}
'Imports Windows.Foundation.Diagnostics
Public Shared Function GetLoggingChannel() As LoggingChannel
    Dim Name = Guid.NewGuid().ToString()
    GetLoggingChannel = New LoggingChannel(Name)
End Function
//using namespace Windows::Foundation::Diagnostics;
static LoggingChannel^ MainPage::GetLoggingChannel()
{
    auto name = (ref new Guid())->ToString();
    auto channel = ref new LoggingChannel(name);
    return channel;
}

C# and VB: LoggingChannel objects should be disposed

Because LoggingChannel objects use system resources, the C# and VB projections of LoggingChannel derive from the System.IDisposable interface to enable you to release the resources before the object is destroyed by the CLR garbage collector. In C++ code, the LoggingChannel object is destroyed and resources are released as soon as the object goes out of scope. Here are examples of patterns that you can use to add user marks to a diagnostics session file:

void MyScenario()
{
    var logLevel = LoggingLevel.Information;
    using(var channel = Utils.GetLoggingChannel())
    {
        channel.LogMessage("MyScenario Start", logLevel);
        // scenario code
        channel.LogMessage("MyScenario End", logLevel);
    }
}

Add marks to JavaScript code

To add user marks add the following code at the points in your code that you want to mark:

if (performance && performance.mark) {
    performance.mark(markDescription);
}

markDescription is a string that contains the message to display in the user mark tooltip.

If your solution contains multiple app projects, make sure the one that you want to analyze is set as the startup project. In Solution Explorer, select the project and choose Set as Startup Project from the context menu.

Choose Set as Startup Project

You can run diagnostic sessions for phone apps on a Windows phone that is directly connected to the Visual Studio computer or in a Visual Studio phone emulator. You can run Windows Store apps on the Visual Studio computer, in the Visual Studio device simulator, or on a remote device that is connected to Visual Studio over a network or that is connected directly to the Visual Studio computer with an Ethernet to USB cable. You can set the deployment target on the Debug page of the project properties, or you can choose the target from the debug location list on the Visual Studio toolbar. Here's the deployment list for Windows Store apps:

Deployment target list for Windows Store apps

The choice that you make on the debug location toolbar is saved to the project properties.

Applies to Windows only

  • Running a diagnostic session on a remote Windows Store device requires that the Visual Studio Remote Tools be installed and running on the remote target. See Run Windows Store apps on a remote machine from Visual Studio.

  • If you have not specified a remote device when you choose the Remote Machine on the debug location list, specify the device in the Remote Connections dialog box that appears.

    Remote Connections dialog box

  • After the remote device target has been specified, you must use the Debug page of the project properties to change to a new device.

  • If you are using a USB to Ethernet cable to connect a remote device with the Visual Studio computer, specify the I.P. address of the remote device in the Remote Connections dialog box.

Besides starting your app from the Visual Studio project, you can also run diagnostic sessions on alternative targets. For example, you might want to diagnose performance issues on a version of your app that was installed from the Windows App Store.

Choose diagnostic tools analysis target

Applies to Windows only

You can start Windows Store apps that are already installed on a device, or you can attach the diagnostic tools to a Windows Store app that is already running. When you choose Running App or Installed App, you select the app from a list that discovers the apps on the specified deployment target.

Choose a running or installed app for diagnosis

Applies to Windows Phone only

When you choose Internet Explorer, you specify the url and you can change the phone deployment target.

Specify the url to display in Internet Explorer

On the Performance and Diagnosis hub, choose one or more tools to run in the diagnostic session. Only the tools that are applicable to the project type and programming are displayed. When you choose a diagnostic tool, the selections for tools that cannot be run in the same diagnostic session are disabled. Here's how your choices might look for a JavaScript app:

To start the diagnosis session, choose Start.

To end the diagnostic session and begin the data analysis, choose Stop collection at the bottom of the page.

When you stop collecting data in a diagnostic session, the data is immediately analyzed and then displayed in the Performance and Diagnostic report.

You can also open saved .diagnosis session files from the recently opened list on the Performance and Diagnostic hub.

Open a saved diagnosis session file

Choose the show or hide button at the top of the Performance and Diagnostic hub to expand or collapse the recently used file list.

Performance and Diagnostics data page

Step 1

The timeline shows the length of the profiling session, app lifecycle activation events, and user marks.

Step 2

You can restrict the report to a part of the timeline by dragging the blue bars to select a region of the timeline.

Step 3

A tool displays one or more master graphs. If your diagnostic session is created with multiple tools, all of the master graphs are displayed.

Step 4

You can collapse and expand the individual graphs.

Step 5

When your data includes information from multiple tools, the details for the tool is collected under tabs.

Step 6

A tool can have one or more detail views. The view is filtered by the selected region of the timeline.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft