WPF Performance Tools and Resources
WPF provides a suite of performance profiling tools that allow you to analyze the run-time behavior of your application and determine the types of performance optimizations you can apply. The following table lists the five performance profiling tools that are included in the Windows SDK tool, WPFPerf:
Tool |
Description |
---|---|
Event Trace |
Use for analyzing events and generating event log files. |
Perforator |
Use for analyzing rendering behavior. |
Trace Viewer |
Record, display, and browse Event Tracing for Windows (ETW) log files in a WPF user-interface format. |
Visual Profiler |
Use for profiling the use of WPF services, such as layout and event handling, by elements in the visual tree. |
Working Set Viewer |
Use for analyzing the working set characteristics of your application. |
The Visual Profiler tool suite provides a rich, graphical view of performance data. In this screenshot, the CPU Usage section of the Visual Profiler gives you a precise breakdown of an object's use of WPF services, such as rendering and layout.
Visual Profiler display output
For more information, see WPF Performance Suite.
Viewing the Visual Tree with XamlPad
Analyzing the visual tree hierarchy using XAMLPad may give you insight into how control template expansion works. This knowledge may help you understand the performance costs and tradeoffs of the user interface design you are creating.
XamlPad provides an option for viewing and exploring the visual tree that corresponds to the currently defined XAML content. Click the Show Visual Tree button on the menu bar to display the visual tree. The following illustrates the expansion of XAML content into visual tree nodes in the Visual Tree Explorer panel of XamlPad:
Visual Tree Explorer panel in XamlPad
Notice how the Label, TextBox, and Button controls each display a separate visual object hierarchy in the Visual Tree Explorer panel of XamlPad. This is because WPF controls have a ControlTemplate that contains the visual tree of that control. When you explicitly reference a control, you implicitly reference its visual hierarchy. For more information on visual objects and the visual tree, see Windows Presentation Foundation Graphics Rendering Overview.
You can view the property settings of an item in the Visual Tree Explorer by selecting the item. The Property Tree Explorer panel, below the Visual Tree Explorer panel, displays the current property settings for the selected visual object.
Property Tree Explorer panel in XamlPad
For more information, see XAMLPad.
Debug Tracing Support for WPF
The PresentationTraceSources class provides debug tracing support that specifically targets WPF applications. Tracing is a diagnostics system by which an application's progression can be tracked. The tracing statements report information, much the way the WriteLine method is often used. However, tracing statements can be switched on or off by using a configuration file. In addition, the output of tracing statements can be customized.
For other related .NET Framework diagnostic classes, see System.Diagnostics.
See Also
Concepts
Optimizing WPF Application Performance
Planning for Application Performance
Optimizing Performance: Taking Advantage of Hardware
Optimizing Performance: Layout and Design
Optimizing Performance: 2D Graphics and Imaging
Optimizing Performance: Object Behavior
Optimizing Performance: Application Resources