.NET 6 performance improvements when comparing two arrays using SequenceEquals

There’s some pretty impressive performance improvements in .NET 6 when we are comparing arrays using the LINQ SequenceEqual method.

The benchmarks below show that on my machine comparing two int arrays of 10K elements was 94 times faster in .NET 6 compared to .NET 5. We can see that there is also impressive improvements when we are comparing string arrays and arrays of complex types.

Click the image for a larger view in a new tab…

If you’re unfamiliar with the LINQ SequenceEqual method check out the page below for some really clear (and runnable) examples which should help you understand when it will return true or false…
SequenceEqual – LINQ Equality Operator (tutorialsteacher.com)

Note… the StudentComparer class is here if you wish to view it.

Leave a Reply

Your email address will not be published. Required fields are marked *