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.
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:
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:
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.
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).
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.
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.
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.
.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.