Bewerken

Share via


Which performance tool should I use? (C#, Visual Basic, C++, F#)

Visual Studio provides a variety of profiling tools to help you diagnose different kinds of app performance issues depending on your app type. In this article, we provide information to help you find the right tool for your scenario and application type.

For a general approach to optimizing code using the profiling tools, see Case study: Beginner's guide to optimizing code.

Which tool should I use?

The following table lists the different tools Visual Studio offers and provides common scenarios for choosing the tool.

Performance Tool Description When to use the tool?
CPU Usage Shows where the CPU is spending time. • Begin an investigation for general performance issues.
• Investigate high server CPU usage.
• Investigate DevOps scenarios, such as when orders are not getting through to the retail website.
• Optimize CPU usage.
• Investigate latency in API calls.
Flame graph View within the CPU Usage tool that provides an alternate visualization of the call tree. Investigate latency in API calls
Hot path View within the CPU Usage tool that shows where most of the CPU time was spent in your application. Investigate latency in API calls
Memory Usage Shows your app’s memory to find issues such as memory leaks. • Optimize memory usage
• Investigate UI freeze
• Investigate suspected memory leak (native code)
.NET Object Allocation Shows where .NET Objects are allocated and information about garbage collection. • Optimize .NET memory usage
• Analyze garbage collection
Instrumentation Shows exact call counts and call times. • You need a tool like CPU Usage, but you want exact call counts and time spent in functions based on wall clock time.
• You want to see blocked time, such as time spent waiting for locks.
• Note: This tool requires extra overhead.
File I/O Shows your File I/O operations and how long they take and how much data they process. Investigate UI freeze
PerfTips Shows a quick measurement of performance information while interacting with your code. While debugging, you want to see the elapsed time between the previous step operation (or breakpoint) to the current step or breakpoint.
Events viewer Shows HTTP requests, log messages, and exceptions. • Investigate latency in API calls
• Investigate slow application running on a remote web server
.NET Async Shows async/await usage in .NET apps. Investigate suspected performance issue with asynchronous code.
.NET Counters Live report for .NET counters. • Begin an investigation for general performance issues.
• You want a trace for .NET counter-based metrics such as exceptions per second, garbage collection, and CPU utilization.
Database Shows performance of your database queries. Investigate performance for database queries that use either ADO.NET or Entity Framework Core.
GPU Usage Shows high-level hardware usage of your Direct3D app. Check whether the performance of your app is CPU-bound or GPU-bound.
Application Timeline Shows UI performance for XAML apps. Investigate UI performance in XAML apps, such as time spent rendering frames.
IntelliTrace Debugger tool that lets you record events and examine your application state at various points of execution. You want a tool to examine application state at various points, not just the current application state.

Which tools are supported for my project?

The following table lists the different tools Visual Studio offers and the different project types you can use them with:

Performance Tool .NET C/C++ UWP ASP.NET/ASP.NET Core
CPU Usage yes yes yes yes
Memory Usage yes yes yes yes
.NET Object Allocation yes no yes yes
Instrumentation yes yes yes yes
File I/O yes yes yes yes
PerfTips yes yes yes yes
Events viewer yes yes yes yes
.NET Async yes no yes yes
.NET Counters yes (.NET Core/5+ only) no no yes (ASP.NET Core only)
Database yes (.NET Core/5+ only) no no yes (ASP.NET Core only)
GPU Usage yes yes yes no
Application Timeline yes (XAML) no yes no
Performance Explorer no no no no
IntelliTrace .NET with Visual Studio Enterprise only no .NET with Visual Studio Enterprise only .NET with Visual Studio Enterprise only

Which tools are supported on Linux?

The following tools are supported with Linux as the target platform as well as Windows:

  • CPU Usage
  • .NET Object Allocation Tracking
  • .NET Async
  • .NET Counters
  • Events Viewer
  • Database

Learn to use the profilers

The following articles and blog posts provide more information to help you learn to use the Visual Studio performance tools effectively.