PerfView - Advanced Performance Analysis Tool

PerfView is a free tool from Microsoft that you can use to analyze performance issues in your applications. It collects and displays a wide range of performance data, including CPU usage, memory allocations, GC events, and more.

Getting Started with PerfView

To begin analyzing your application's performance, you typically follow these steps:

  1. Download PerfView: Download the latest release of PerfView from the official Microsoft GitHub repository.
  2. Run PerfView: Launch PerfView. It's a portable executable, so no installation is required.
  3. Collect Data:
    • Click the "Collect" button in the main window.
    • Choose the type of data you want to collect. For general CPU and memory analysis, "CPU+GC" is a good starting point.
    • Click "Start Collection".
    • Run your application or perform the actions you want to profile.
    • Click "Stop Collection" in PerfView when you are finished.
  4. Analyze Data: PerfView will display a summary of the collected data. You can then drill down into various views to understand performance bottlenecks.

Key Features and Views

Common Scenarios and Usage

CPU Profiling

To capture CPU sampling data:

PerfView.exe collect -EventBufferMB 1024 -Providers "Microsoft-Windows-SampleProfiler"

After collection, open the .etl file in PerfView and look for the "CPU Usage (Sampled)" view.

Memory Allocation Profiling

To capture memory allocation data:

PerfView.exe collect -providers "Microsoft-DotNETRuntime:0x10,Microsoft-Windows-DotNETRuntimeGC:0x1"

This collects data for .NET Runtime and Garbage Collector events. You can then explore the ".NET Object Allocations (Bytes)" or ".NET Object Allocations (Count)" views.

Note: For the best results, ensure that symbols are correctly configured in PerfView. This is usually handled automatically, but manual configuration might be needed in some environments.

Learning Resources

Tip: Use PerfView's search functionality extensively to find specific events, functions, or types within large trace files.