Compartilhar via


Analyze performance of .NET asynchronous code

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Use the .NET Async tool to analyze the performance of asynchronous code in your app.

Note

The .NET Async tool requires Visual Studio 2019 version 16.7 or later and a .NET project that uses async and await.

Setup

  1. Select Alt+F2 to open the performance profiler in Visual Studio.

  2. Select the .NET Async check box.

    .NET Async tool selected

  3. Click the Start button to run the tool.

  4. After the tool starts running, go through the scenario you want to profile in your app. Then select Stop collection or close your app to see your data.

  5. After collection stops, you see a table of the activities that happened during your profiling session.

    .NET Async tool stopped

Asynchronous events are organized into activities chronologically. Each displays its start time, end time, and duration.

Each row that corresponds to a task is labeled in the Name column. For any task name that can't be resolved, a Task in label appears. It's followed by the name of the method the task occurs within. If an asynchronous activity doesn't complete within the collection session, an Incomplete label appears in the End Time column.

To further investigate a specific task or activity, right-click the row. Then select Go To Source File to see where in your code that activity happened.

.NET Async tool with Go To Source File selected

See also