Skip to content

Using PerfView for ETW Tracing

Jon Wagner edited this page Mar 4, 2013 · 1 revision

Using PerfView for ETW Tracing

PerfView is a self-contained analysis tool for ETW and the CLR. Microsoft uses it internally for many of the teams, and it's the primary performance investigation tool for the .NET Runtime team.

Download PerfView from Microsoft Downloads: PerfView

You can collect performance metrics system-wide, or just when a process is running. Start up PerfView and select Run or Collect from the Collect menu. You get a big box of choices on what types of things to collect. You can collect just about anything.

We want to collect information about our custom EventSource:

  1. Start up PerfView and select Run or Collect from the Collect menu.
  2. Open up Advanced Options.
  3. In Additional Providers, enter *ICalculatorEventSource or the GUID of the provider. (See Getting the EventSource Manifest or GUID).
  4. Run your tracing.
  5. Look at the results.

You can control the amount of data that PerfView traces. Additional Providers takes a string in the form provider:keywords:level:stack:values. You can choose how specific you want to filter:

  • provider - for this, we use *providername to select our provider
    • Note that since our class is dynamically generated at runtime, you cannot use the @ syntax as described in PerfView help.
  • keywords - a 64-bit hex number that specifies the keywords to log. We can use this bitmask to trace only certain events. Specify 0xFFFFFFFF or * to log everything.
  • level - a number from 1 to 5, with 1=Critical through 5=Verbose. Default is Verbose.
  • stack - the word 'stack' to log stack traces for every event.
  • values - a list of KEY=VALUE pairs passed to the provider. (I haven't tried this yet.)

You can also run PerfView from the command line. See PerfView for more details.