Performance is one of the key pillars we consider when developing UI controls. We are committed to continuously look for better strategies to improve the performance of every control we create. In .NET 5, FlexGrid for WPF was reassessed and redesigned to overcome some bottlenecks we found in previous versions.

This blog shows the criteria used to develop our .NET 5 datagrid, FlexGrid, and compares its performance to other WPF datagrids on the market.

Try ComponentOne Studio

Download the latest version of ComponentOne Studio Enterprise

Download Now!

Background

The two most important aspects to consider when measuring the datagrid performance are loading and scrolling. Scrolling performance is typically more important since loading occurs only once, but scrolling happens constantly–making it much more visible to users.

Of course, loading is significant too, so it is important to resolve these two aspects together to find a suitable balance.

Since datagrids must support displaying large data sets with millions of items, creating the cells for each item is impractical in terms of load-time and memory consumption. Instead, a technique called UI virtualization is used, which displays only what the user can see.

As the user scrolls the grid, the new viewport is recreated underneath and displayed, giving the user the feeling that it was already there.

UI virtualization is beneficial and necessary for optimized loading performance. Still, it doesn't solve the problem at scrolling time. It's necessary to recreate the visual tree to show the new elements every time a scroll event happens–frequently and in a brief lapse of time.

This means that it is crucial to have a fast layout to show all the cells in the viewport as quickly as possible. Since creating the cells and adding them to the visual tree takes a considerable amount of time, recycling the cells will help us reduce the time involved in computing the layout.

On the other hand, UI virtualization does not solve everything. If we use a huge data source, the row collection will have as many rows as items in the source, and simply creating this number of objects brings loading time penalties.

To avoid this, the model virtualization technique is implemented, which results in delaying the creation of columns and rows until they are needed.

The Numbers

To make performance comparisons, we tested all three of our WPF datagrids and compared them against the Microsoft datagrid. The four datagrids tested are:

  1. Microsoft DataGrid for WPF (.NET 5)
  2. ComponentOne FlexGrid for WPF (.NET Framework 4.5.2)
  3. ComponentOne Legacy DataGrid for WPF (.NET Framework 4.5.2)
  4. ComponentOne FlexGrid for WPF (.NET 5)

These datagrids were tested in a .NET 5 application to ensure that each datagrid shows the same number of cells. Results were averaged from multiple tests.

See the data below to view the initial results for scrolling versus loading for 1,000 rows, 10,000 rows, 100,000 rows, and 1 million rows.

Scrolling Performance

scrolling performance

Loading Performance

loading performance

The Results

Our performance comparison resulted in the following takeaways:

  • The scrolling performance of the .NET 5 FlexGrid is 3x times faster than Microsoft DataGrid and 1.8x times faster than its WPF .NET Framework 4.5.2 predecessors
  • The loading performance of the .NET 5 FlexGrid is 3.2x times faster than Microsoft DataGrid, 2.3x faster than C1DataGrid, and very similar to the 4.5.2 FlexGrid with few items

The .NET 5 FlexGrid now has the most consistent performance for any number of rows and shows the fastest loading and scrolling times in every scenario.

It fixes the problems found in .NET Frameworks regarding loading large data sources through the model virtualization implementation.

Try ComponentOne Studio

Download the latest version of ComponentOne Studio Enterprise

Download Now!