Skip to main content Skip to footer

.NET 6 WinForms Chart Control Performance Metrics

At the end of 2021 .NET 6 was released, which became a huge milestone in the .NET ecosystem’s development. Among a lot of various improvements .NET 6 declares massive gains in performance. We already published our performance research for data grid components: WPF Datagrid Performance and FlexGrid for WinForms. Of course, it’s also interesting to check how fast our charting components would work on the new platform. The FlexChart is a complex control involving a lot of different operations: data binding, data processing, graphical output, etc.

Tests and Measurements: WinForms Chart Control

We have our set of performance tests that was created several years ago. The benchmark application was ported to .NET 6 and has almost the same source code as for .NET 4.5.

The most important characteristic is how fast you can get a chart from the data. In the benchmark we measure the total time of chart creation which includes a set of common basic operations:

  • create chart
  • add chart to the form, 
  • set chart data 
  • set chart type
  • repaint chart using Refresh() method.

The elapsed time was measured using the system Stopwatch timer.

For the benchmark we selected the most useful chart types: Column, Line, Scatter, LineSymbols, Area. The integral result includes the sum of rendering all chart types. The number of data points varies from 100 to 30000 to check performance with different sizes of data.

The benchmark application was built using the latest stable WinForms FlexChart versions at the moment of testing (NPM packages 4.5.20213.532 for .NET 4.5 and 6.0.20213.532 for .NET 6). The tests run using both supported render modes: default (GDI+) and high-performance DirectX (Direct2D).

Environment: the tests were performed on desktop pc:

  • CPU: i5-4590 CPU
  • GPU: integrated
  • RAM: 16.0 GB RAM
  • OS: Windows 10 Pro 21H1 19043.1526, 
  • .NET Runtime: ‘classic’ .NET version 4.8.04084 and newest .NET 6.02.

Each test was run 100 times, then the average time and dispersion were calculated to check reliability and reproducibility of results. The test results exhibit good quality with dispersion only a few percent.

Results

Let’s look at the most interesting part - the results. The following chart shows the total time (sum of times for rendering all chart types).

WinForms Chart Control Performance

As you can see, .NET 6 is faster for all chart types and rendering modes. For a cleaner presentation, we can plot only performance gain on the next chart.

WinForms Chart Control Performance

Let's have a look at specific chart types. The most interesting case is the Scatter chart, which has the largest performance gain 17-38% for default render mode and 36-57% for DirectX mode. 

WinForms Chart Control Performance

It’s quite surprising that default rendering on .NET 6 became as fast as DirectX on .NET 4.5. The possible reason is a set of optimizations in .NET and compiler which are especially favorable for scatter charts that create many small graphics objects.

Conclusion 

.NET 6 is indeed faster than .NET 4.5. That can be a very good reason to switch; for the FlexChart you'll get 15-20% performance gain almost for free. It may be interesting to look into the details and find which specific parts of the code improved in "new" .NET but it could be a subject of a special research.

Attachments

comments powered by Disqus