(I’m getting to the point in a roundabout way… you can skip directly to the point below if you want.)
When I started working on my WPF-Wii tutorials, my first Wii project was the initial version of the WPF-Wii Visualizer.
However, I quickly got tired of writing the code for handling events and transferring the data from the Wiimote library to my application. So (like any noble geek would do) I wrote even MORE code to solve the problem, not only for myself, but for generations to come.
I’ve spend the last week writing a Wii-To-WPF library that shovels the Wiimote properties into properties that use the INotifyPropertyChanged WPF interface. This will allow anyone to connect to the Wii through the WPF data binding. It’s super cool.
(A point of note, I posted an early version of this library. Ignore it. I’m putting up a much improved version in the next couple days.)
But I had no idea how moving from a basic data transference and event handling to the INotifyPropertyChanged interface would affect my performance.
Here are some screenshots of Perforator (a WPF performance monitoring application) monitoring my WPF-Wii Visualizer in its code-heavy iteration:
I don’t know what all those numbers mean, but the one I’m interested in is the frame rate. As a designer, smoother motion is good… especially if I’m trying to design a multi-point application. A frame rate of 27 isn’t too bad, but this is the best I got. The frame rate usually hovered around 20, dipping as low as five.
Now… this is what I got when I was binding the data through the XAML (absolutely no code whatsoever):
And this was the worst I got. My frame rate was always in the mid 60s and would spike up to 80. Take note that I’m not changing the interface at all. In fact, I’m running the binding version at a handicap (it’s tracking four infrared points instead of the original two).
Exact same XAML … except that the XAML properties are data bound from within the XAML and not assigned via the C# code.
So, lets take an account of the WPF INotifyPropertyChanged interface:
- Allows DataBinding
- Permits code-light or code-free interface design
- Drastic improvements to performance