Skip to main content Skip to footer

.NET 8 Datagrid Performance Benchmarks in FlexGrid for WinForms

Quick Start Guide
What You Will Need

Visual Studio 2022, ComponentOne WinForms Edition, BenchmarkDotNet +

Controls Referenced

FlexGrid for WinForms +

Tutorial Concept .NET 8 WinForms Datagrid Performance - This comparison will show the difference in performance for FlexGrid, a .NET datagrid control, across .NET version 6 and 8 in a WinForms application.

With the recent .NET 8 release, you may be wondering if the upgrade is worth the cost. In this blog, let’s look at the performance of our powerful WinForms datagrid control, FlexGrid, for .NET 8 compared to .NET 6.

.NET 8 Performance Improvements

.NET 8 uses the JIT (Just In Time) - compiler, similar to previous versions, but it now processes code faster and lessens the process execution time. The garbage collector performance has also improved by allowing you to dynamically adjust the memory limit - this is most useful for cloud solutions where you may need to scale the resources based on demand.

The biggest reason to upgrade your .NET applications is usually performance, but yet again, Microsoft is pushing the performance limitations with each version of .NET. This makes it the number one reason to migrate for any .NET platform.

How to Measure Performance in .NET 8

The popular BenchmarkDotNet tool can be used for straightforward performance measuring of your .NET code. Not only does it measure time and memory allocation, but you can also compare different versions of .NET along with different benchmark tests. You can also use parameters like number of rows and columns. It runs and outputs all the results in a single report.

You can read more about configuring the BenchmarkDotNet in our previous blog, How to Compare Performance between .NET 5 and .NET Framework Controls.

For the tests below, we’re testing FlexGrid for WinForms .NET 6 compared to .NET 8. These are long-term support versions. We’re generating data with 20 columns and a range of rows from 10,000 to 1 million. Let’s get to the results!

FlexGrid for .NET 8 Benchmark Results

FlexGrid is our powerful, cross-platform .NET datagrid, which is supported in WinForms, WPF, WinUI, UWP, Xamarin, ASP.NET Core, and even MAUI. The following benchmarks are performed for the WinForms FlexGrid.

  • Paint the Datagrid
  • Assign Data to the Datagrid
  • Filter Columns
  • Sort a Column
  • Group a Column
  • Autosize Columns

Ready to Check It Out? Download ComponentOne Today!

Benchmark: Paint the Datagrid

The paint benchmark measures the time and memory used to draw the control. This can invoked by the Refresh method.

_flexGrid.Refresh();

Results:

Number of rows

Mean time (ms)

Memory allocated (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

10000

84.555

82.025

359.77

363.96

100000

91.157

82.288

359.77

363.96

1000000

80.506

77.072

359.77

363.96

Paint FlexGrid .NET 8

Observe that the drawing time and memory allocated are about the same regardless of the .NET version or number of rows. This is because the datagrid only draws the visible rows. The .NET 8 version is just 3-10% faster.

Benchmark: Assign Data to the Datagrid

This benchmark sets the datasource and a data-mapped column. The data is generated outside of the benchmark test.

_flexGrid.DataSource = _data.DataTable;
_flexGrid.Cols[columnIndex].DataMap = _data.DataMaps[dataMapIndex];

Results:

Number of rows

Mean time (ms)

Memory allocated (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

10000

11.945

12.096

1583.77

1583.7

100000

63.697

55.059

14943.13

14943.09

1000000

604.41

590.135

148537.49

148537.24

FlexGrid Assign Data .NET 8

Observe that more memory and time are used to assign larger data sources, but there’s not much difference between .NET 6 and .NET 8. The .NET 8 version is merely 2-13% faster.

Benchmark: Filter Columns

The filtering benchmark creates and applies two conditional filters using the following test code.

_flexGrid.AllowFiltering = true;
ConditionFilter conditionFilter = (_flexGrid.Cols[_flexGrid.Cols.Fixed].Filter as ColumnFilter).ConditionFilter;

Condition condition1 = conditionFilter.Condition1;
condition1.Operator = ConditionOperator.GreaterThan;
condition1.Parameter = _condition1Parameter;

Condition condition2 = conditionFilter.Condition2;
condition2.Operator = ConditionOperator.LessThan;
condition2.Parameter = _condition2Parameter;

_flexGrid.ApplyFilters();

Results:

Number of rows

Mean time (ms)

Memory allocated (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

10000

20.476

17.45

939

939.02

100000

167.649

118.522

9376.5

9376.52

1000000

1356.267

1066.629

93751.5

93751.52

FlexGrid Filter Columns .NET 8

Observe the .NET 8 version is 15-21% faster!

Benchmark: Sort a Column

The sorting benchmark sorts a single column using the FlexGrid’s sort method.

_flexGrid.Sort(SortFlags.Ascending, 1);

Results:

Number of rows

Mean time (ms)

Memory allocated (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

10000

10.755

9.566

614.41

614.23

100000

166.266

159.876

6144.84

6144.66

1000000

2959.98

2968.626

63296

63295.82

FlexGrid Sort Column .NET 8

Observe there’s no dramatic improvement between .NET 6 and .NET 8 for a million rows. However, the .NET 8 version is 4-11% faster for small and medium-sized data sources.

Benchmark: Group a Column

The grouping benchmark groups a single column by adding a group descriptor to the FlexGrid.

_flexGrid.GroupDescriptions = new List<GroupDescription>()
{
    new GroupDescription(_flexGrid.Cols[_firstDataMapColumnIndex].Name, ListSortDirection.Ascending)
};

Results:

Number of rows

Mean time (ms)

Memory allocated (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

10000

89.637

60.967

1935.67

1935.59

100000

997.231

779.149

13091.7

13091.39

1000000

10428.79

8577.146

126493.31

126493.23

FlexGrid Group Column .NET 8

Observe that the larger the data source, the more time is gained with .NET 8. But with smaller data sets, there is a higher percentage of performance gains (31% with 10k rows compared to 18% for 1M rows)

Benchmark: Autosize Columns

Auto-sizing the columns to fit the contents is an expensive feature, but sometimes, it’s worth the performance cost. This benchmark uses a flat 10,000 rows measured against different column counts.

_flexGrid.AutoSizeCols();

Results:

Number of columns

Mean time (ms)

Memory allocation (KB)

 

.NET 6

.NET 8

.NET 6

.NET 8

20

1033.5

871.4

135.34

130.76

50

2508

2251.1

333.09

322.03

100

5226.4

4400

663.41

641.67

200

10682.3

8574.7

1327.88

1284.39

FlexGrid Autosize Columns .NET 8

Observe the .NET 8 version performs faster and has better memory allocation for this operation for all data source sizes. The improvement gains range from around 15 to 20%.

.NET 8 Benchmark Conclusion

While memory allocation is comparable between .NET 6 and .NET 8, these benchmarks demonstrate that .NET 8 offers faster run times to perform various datagrid operations:

  • Painting the datagrid is 3-10% faster
  • Assigning data is 2-13% faster
  • Filtering columns is 15-21% faster
  • Sorting a column is 4-11% faster
  • Grouping a column is 18-31% faster
  • Autosizing columns is 15-20% faster

Overall, .NET 8 is anywhere from 2 - 31% faster than .NET 6, depending on which feature you’re using and the size of your datasource.

How to Test the Benchmarks Yourself

Download the sample to test the benchmarks for yourself. Note that these tests can take a long time to run, so it’s advised to follow these tips before running them. The attached sample can be run using the following command in the Developer Command Prompt.

dotnet run -c Release -f net6.0-windows --project FlexGridBenchmark8 --runtimes net6.0-windows net8.0-windows --filter **

Also, you can fine-tune which tests run by either the command or by simply excluding various class files from the Benchmark folder.

Ready to Check It Out? Download ComponentOne Today!

comments powered by Disqus