String.Equals with OrdinalIgnoreCase faster in .NET 8 compared with .NET 7

There’s some awesome string comparison OrdinalIgnoreCase improvements coming in .NET 8, although I did see one regression too.

Click on the benchmarks for a larger view in a new window …


Looks like a lot of the benefit comes as the strings to compare get larger while for smaller strings the change in some instances may have an overhead but I think this a good trade off IMHO as comparisons with smaller strings will likely be fast already.

This improvement should help a lot of apps as string comparison is such a frequent use case.

PR responsible for performance change
Vectorize String.Equals for OrdinalIgnoreCase by EgorBo · Pull Request #77947 · dotnet/runtime (github.com)

Benchmark code if you’d like to try and re-create
.NET 7 v .NET String.Equals OrdinalIgnoreCase benchmarks (github.com)

Leave a Reply

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