Get the latest tech news
Span<T>.SequenceEquals is faster than memcmp
What could be faster than memcmp? How to quickly compare arrays using Span
There is a bizarre performance regression from .NET 8 to .NET 9 for 1GB arrays, which I will investigate separately to try to confirm that result, it may have been a glitch in the benchmark, given twice the memory allocations and twice the time taken. It's still very fast, much faster than naive methods, but it's clearly no longer necessary for achieving high performance for array comparisons. When the original stackoverflow answer was written, there was nothing available in .NET that could come close to that performance, as it was before Span<T> was added to the runtime.
Or read this on Hacker News