Tuesday, January 14, 2014

I like Windows Presentation Foundation (WPF) very much, especially its implementation of the Model-View-Controller (MVC) design pattern. I've also grown to appreciate XAML as a declarative (if quirky) way of building complex user interfaces that integrate with a testable code file. However, every once in a while, I end up with a WPF Window that takes a long time to render, or renders in a bizarre series of jumps. If that's happened to you, it's worthwhile to download Microsoft's WPF Performance Suite.

The suite includes two tools: Perforator and Visual Profiler. Neither will tell you what to do to fix your problem, but both will help you locate the problem.

Perforator concentrates on the low-level routines that render your XAML. The download page for the package includes some useful information ...

While Perforator looks at how WPF is rendering your XAML, Visual Profiler shows how individual ...

The Windows SDK includes a suite of performance profiling tools for Windows Presentation Foundation (WPF) applications called the WPF Performance Suite. The WPF Performance Suite enables you to analyze the run-time behavior of your WPF applications and determine performance optimizations that you can apply. The WPF Performance Suite includes performance profiling tools called Perforator and Visual Profiler. This topic describes how to install and use the Perforator and Visual Profiler tools in the WPF Performance Suite.

Perforator is a performance profiling tool for analyzing the rendering behavior of your WPF application. The Perforator user interface displays a set of graphs that enable you to analyze very specific rendering behavior in parts of your application, such as the dirty rectangle addition rate and the frame rate. WPF uses a rendering technique called dirty rectangle, which means that only the portions of the screen that have changed are rendered on a new rendering pass. In addition, Perforator has several options that you can use to look for specific rendering problems. Perforator also reports the software rendering targets and a slider to control the duration of the graphs. The following illustration shows the Perforator user interface.

Visual Profiler is a performance profiling tool of WPF services, such as layout, rendering, and animation, for elements in the visual tree. By analyzing the profiling output of this tool, you can determine which visual elements in your application may be causing performance bottlenecks.

Visual Profiler presents performance issues in the context of the basic building blocks that are used to construct visual scenes in your application. These building blocks include high-level objects, such as Button and TextBlock controls, as well as low-level objects, such as Line and Ellipse elements. Instead of describing performance issues in terms of call graphs of functions names, Visual Profiler describes these issues by using the representation of visual objects. This is similar to the way the Windows SDK tool, UI Spy, represents information. For more information, see UISpy.exe (UI Spy).

Some pretty cool utilities that I don't remember seeing before... I'm almost afraid (heck, no almost about it) to run them on my WPF LOB app's... :/