Wpf Toolkit

Wpf Toolkit Average ratng: 8,1/10 9983 votes

This blog has moved to a new location and comments have been disabled. All old posts, new posts, and comments can be found on The blog of dlaa.me.

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. This topic contains the following sections:.

The following steps describe how to install the WPF Performance Suite. If you have an earlier version of the Windows Performance Toolkit installed, uninstall it. Install the Windows SDK. In the installation options, make sure that you select the Windows Performance Toolkit option under Common Utilities. For download information, see the. After the Windows SDK is installed, on the Start menu, select All Programs, Microsoft Windows SDK v7.1, and then Tools.

Under Tools, click Install Windows Performance Tool Kit. The setup wizard appears. Follow the instructions that appear to install the Windows Performance Toolkit.

By default, the following features will be installed. Performance Analyzer.

Windows Performance Toolkit Help. GPUView. WPF Performance Suite. You should start the WPF Performance Suite before you run the application that you want to profile. To use the WPF Performance Suite, your user account must have administrative privileges.

The following steps describe how to start the WPF Performance Suite. On the Start menu, select All Programs and then Microsoft Windows Performance Toolkit. Click WPF Performance Suite. If a User Account Control dialog box appears, click Yes. The WPF Performance Suite starts.

Wpf Toolkit Example

The first time that you start the WPF Performance Suite, the Add Tools dialog box appears. The Add Tools dialog box lets you add performance profiling tools. To add a tool, you select an assembly that contains a tool and then click Scan Assembly.

Wpf Toolkit Datagrid

Wpf toolkit june 2009

You can open the Add Tool dialog box at any time by clicking Add Tool from the File menu. The following illustration shows the Add Tools dialog box. 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. To use Perforator, start the WPF application that you want to analyze.

Once the application has started, click the Perforator tab, click the Actions menu, and then click Select Process. In the Select Process dialog box, select the application process that you want to analyze and then click Select.

The process name and process ID should now appear at the top of the Perforator tab. Select rendering options that you want to analyze. The Perforator data values, such as frame rate, immediately reflect the rendering behavior of the application. The following illustration shows an example. History Graph Description Notes Frame Rate Reports the rate at which the application is rendering to the screen.

For applications without animation, this value should be near 0. During animations in a well-performing application, Frame Rate should be close to the monitor’s refresh rate (typically 60 or 75). Dirty Rect Addition rate Indicates how many rectangular regions that WPF has to update for each frame. Dirty rectangle refers to a rendering technique where only the portions of the screen that have changed are rerendered. A high value indicates that a lot of regions are changing. This isn't necessarily good or bad but a value to consider with the overall performance of your application.

SW IRTs Per Frame Shows the number of software intermediate render targets (IRTs) required to render one frame of the application. IRTs are expensive software surfaces that WPF must allocate and copy data to and from. Software IRTs are more expensive than hardware IRTs. IRTs are usually caused by using, property on a, or Tile modes on a. If this number is high (for example, greater than 5), it indicates that the WPF runtime is performing a large amount of work to render your application. On a computer that supports hardware acceleration, this number should be 0. Otherwise, this number indicates that some of your scene is rendered by using the slower software pipeline.

HW IRTs Per Frame Shows the number of hardware intermediate render targets (IRTs) required to render one frame of the application. IRTs are expensive hardware surfaces that WPF must allocate and copy data to and from.

Intermediate render targets are usually caused by using, or property on a, or Tile modes on a. If this number is high (for example, greater than 5), it indicates that the WPF runtime is performing a large amount of work to render your application. In this case, you will have to analyze all areas of your code that use the previously mentioned elements. Hardware IRTs are less expensive than software IRTs.

Video Memory Usage Tracks large allocations of video memory to WPF for texture and render targets. This metric does not track memory allocations to the video driver or memory allocations for compiling and loading pixel and vertex shaders. Exceeding the available amount of texture memory will usually cause WPF render logic to fall back to software, and that multiple displays (multi-monitor) have a multiplicative effect on the amount of video memory that is required for an application. Because the WPF hardware rendering pipeline is significantly faster that its software rendering pipeline, the less application user interface that renders in software, the faster rendering in that application will be. Typically, the time that it takes to render an area in software is proportional to the number of pixels rendered.

Therefore, be wary of large areas rendered by using the software pipeline. Small areas are of less concern. The following table lists the Perforator options that can help detect software rendering issues. Option Description Notes Draw software rendering with purple tint Draws all areas rendered by using the software rendering pipeline with a purple tint.

This includes software render targets, software 3D content, and per-primitive software fallback. The WPF hardware rendering pipeline is significantly faster that its software rendering pipeline. Too much software rendering typically indicates a problem. Examples that would cause this behavior include tiling a too much or exceeding the video card’s texture size. Draw software rendered bitmap effects with red tint Draws legacy software rendered bitmap effects with red tint.

Software rendered classes are slow and should be avoided. You should use the hardware rendered classes that were introduced in the.NET Framework 3.5 SP1.

The following illustration displays the PhotoDemo sample application with the Draw software rendering with purple tint rendering option enabled. Option Description Notes Show dirty-region update overlay Causes each update WPF makes to the screen to be indicated by re-coloring. This enables you to see when and where areas are redrawn in an application.

Because WPF only updates portions of the window as required, it can be helpful to visualize what proportion of the window is being updated at any time. Use this option when frame rate and dirty rectangle addition rate are not zero, but no visuals are changing in your application. Disable dirty region support Causes WPF to redraw the entire window any time a change is made.

This option is useful for forcing your entire window to update. Normally, only the portion of the window that has changed is redrawn. Enabling this option causes your application to render much more slowly. Clear back-buffer before rendering Clears application windows before each drawing operation. This option is an alternative to Show dirty-region update overlay.

It effectively shows the most recent dirty region whereas the dirty region update overlay is more useful for seeing changes in the dirty region over time. Option Description Notes Disable Opacity Effects Disables certain potentially performance-intensive uses of opacity. To avoid this performance issue in general, consider setting opacity on a low-level object, such as, instead of a high-level object, such as. Disable per-primitive software fallback Disables software fallback for individual rendering primitives. Software intermediate render targets and other software rendering cannot be disabled. This option is not required in most cases.

Keep it unchecked. Disable high-quality image rescaling Disables the rescaling of large images to smaller sizes.

Enables you to see the effect of image rescaling in your application. If checking this option significantly lowers your frame rate, consider decoding your images to a size near the size that they will be displayed. Disable 3D rendering Disables all 3D rendering operations Enables you to see the effect of 3D rendering operations in your application. 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 and controls, as well as low-level objects, such as and 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.

To use Visual Profiler, start the WPF application that you want to analyze. Once the application has started, click the Visual Profiler tab, click the Actions menu, and then click Select Process.

In the Select Process dialog box, select the application process that you want to analyze and then click Select. The process name and process ID should now appear at the top of the Visual Profiler tab. To analyze the breadth of WPF performance issues, you must understand the role and scope of underlying WPF services. These services include layout, rendering, and animation. Visual Profiler provides a graphical representation of how WPF services are allocated among application objects.

For example, when Visual Profiler displays the visual tree of application objects, it overlays different shades of red on the objects in order to represent the relative amount of resources the object is using. An object that is displayed with a darker red overlay represents an object that uses a higher proportion of resources than an object with a lighter red overlay. More importantly, Visual Profiler provides a breakdown of the amount of specific WPF resources an object consumes. The following illustration shows the Visual Profiler user interface. Element Label Part Description Border Type of the element. 'border1' Name of the element. (26) Subtree size.

Wpf Toolkit

0.02% (I) Percent of total size for inclusive tree, which is the element and all its descendants. 0.00 (E) Percent of total elements for the element only.24 ms (I) Time in milliseconds to layout the element and its descendants. 0.00 ms (E) Time in milliseconds to layout the element only. Use the View menu to control whether to display Inclusive/Exclusive%/time information.

Right-click an element to expand or collapse the subtree. You can also expand its hotpath. The hotpath shows the element in the subtree that consumes the most CPU in that subtree. Application events Description Unlabeled Time Time spent in WPF that is not categorized in another application event all time spent by the application outside of WPF RenderMessageHandler (MediaContext) Occurs when the render pass is initiated.

This event causes the time manager to tick among other things. Rendering Thread Occurs when executing rendering instructions on the rendering thread.

This is useful for detecting render-bound applications. Layout Occurs during the measure, arrange, and render pass. UpdateRealizations Occurs when updating internal bitmap representations of text and bitmap effects. Tick (TimeManager) Occurs when the animation is ticking. This event can trigger the animation render handler. When you animate objects in WPF, a time manager manages the objects created for your timelines. The time manager is the root of a tree of objects and controls the flow of time in that tree.

A time manager is automatically created for each WPF application and is invisible to the application developer. The time manager 'ticks' many times per second. The actual number of ticks that occur each second varies depending on available system resources. AnimatedRenderMessageHandler (MediaContext) Occurs for animation processing and updates.

When animations are enabled, this handler processes and updates the animation, which causes properties to change and rendering to occur. Render (MediaContext) Occurs during the render pass.

This method eventually calls the method of each element, and is useful for understanding the total cost of for all elements. This event corresponds to the MediaContext.Render method in a Visual Studio Profiler (VSP) file.

Wpf toolkit example

The Control Options section contains three toggle buttons that perform the following actions. Click the first toggle button to pause or start the Visual Profiler data collection. Click the Live Preview toggle button to display a live preview of the application in the Preview section. Click the Overlay Window toggle button to add a yellow border around the selected visual element. Also, for elements that consume the most CPU time, a red overlay is added. The same red color is used for the element in the Element Tree section.

The intensity of the red correlates to the CPU usage.

Posted on