Since WPF's first release, people keep discussing whether its performance is comparable with WinForms, or whether this platform will eventually die. Now we're seeing the same questions about UWP. Let's try to answer with actual data about our FlexGrid performance.
WinForms is the oldest desktop platform in .NET stack. While Microsoft hasn't released many big changes, it's stable and comparable with latest OS versions, and it's still one of the most popular platforms for .NET development. WPF platform is newer than WinForms and still evolving. At the end of 2014, Microsoft announced WPF roadmap, which focused on quality and performance. And the latest .NET Framework updates prove that they keep moving in this direction: .NET 4.6.1, .NET 4.6.2. UWP is another XAML platform that's being actively developed. Microsoft released several platform updates since the first version, and they're also trying to be more transparent and announced publicly the Windows Platform bug tracker and Windows Platform roadmap. This platform allows you to write applications that can run on any Windows 10 device, including smartphones and tablets. It's much more than desktop, so even if it is new and still has issues, it's promising.
FlexGrid for Desktop
If you need to display tabular data, you can't live without a grid in your application. Data-driven grid controls that are automatically populated based on data source, with sorting, filtering and grouping support, became a standard thing in .NET world. All control vendors have them. Microsoft also ships some basic implementation almost for all platforms. Only UWP doesn't include any datagrid out-of-the-box. We include the FlexGrid control in all our editions. WinForms version is the oldest one. WPF's version is stable and has a lot of extensions. UWP version still has some items in to-do list, but it's already stable and fast.
Our FlexGrid Performance Tests
For the 2017 v1 release, we focused on XAML FlexGrid performance and made significant progress, especially for UWP version. As a part of this job we made performance benchmarks for WPF and UWP datagrids. The full source code of all tests is attached to related blog posts. As soon as we have same tests for all desktop versions, we can try to compare FlexGrid performance on different platforms. Note: it's important to understand limitations of such comparison:
- Even when running on the same machine in the same environment, exact numbers might be a bit different every next time. Windows is not a real-time OS and always has some background processes running.
- WinForms platform is very different from XAML, so we have different implementations for all tests here.
- For WinForms version we use WindowsFormsHost which might add some overhead.
- WPF version uses standard ListCollectionView while UWP version uses our own C1CollectionView implementation.
- UWP platform shows different performance depending on compilation options. Debug version might be faster than release. All our numbers were taken with the release version compiled with .NET Native tool chain (this is what your customers will get from Windows Store) with Microsoft.NETCore.UniversalWindowsPlatform 5.2.2 version. Microsoft released VS 2017 and Microsoft.NETCore.UniversalWindowsPlatform 5.3.0 with significant performance improvements on March 7, 2017. If you have performance problems with your UWP app, check it out with new versions.
- UWP and WPF platforms use hardware acceleration and have a lot of async operations. To measure times, we tried to catch the moment when all layout operations are finished. But there's still a possibility that time measurement on these platforms is not 100% accurate.
- WPF applications might use different levels of hardware acceleration depending on environment. Or if running on machines with low-level GPU, might use software rendering mode. So you can get very different performance depending on your hardware.
Test Results: Let's check the progress
Now let's look at numbers. Here's what we got for 2017 v1 release:
For comparision, here is what tests for 10,000 rows showed with 2016 v2 release:
- XAML grids look really comparable with WinForms one. In most tests end-user won't notice any visual difference.
- Sorting, filtering and grouping performance depends on CollectionView implementation. Apparently C1CollectionView implementation in UWP version is close to what MS does in ListCollectionView for WPF. In both cases, it's possible to use CustomSort to improve sorting performance on big data sources if it is critical for your application.
First loading time is the best in UWP version. This is not only our optimization, but also an effect of .NET native compilation. Applications compiled with .NET native tool chain don't need JIT compilation at run time, so you get better startup performance.
- Read more about UWP FlexGrid benchmark application
- Download benchmark results (.xls file 52KB)
- MSDN: Optimizing WPF Application Performance.aspx "Optimizing WPF Application Performance")
- MSDN: UWP Performance Recommendations