-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Description
StreamsComparer currently compares the bytes of two streams and reports on the index of the first difference. It does this by reading the streams 4096 bytes at a time into buffers and comparing the arrays byte-by-byte.
Some of the new .NET APIs allow for vectorized equality checks on Span<byte>. It may be worth investigating if there's a performance benefit to check for buffer equality via MemoryExtenions.SequenceEquals() and falling back to a byte-by-byte check to determine the failure point if the two buffers are known to be unequal.
nunit/src/NUnitFramework/framework/Constraints/Comparers/StreamsComparer.cs
Lines 57 to 64 in c9fe0e7
| for (long readByte = 0; readByte < xStream.Length; readByte += BUFFER_SIZE) | |
| { | |
| binaryReaderExpected.Read(bufferExpected, 0, BUFFER_SIZE); | |
| binaryReaderActual.Read(bufferActual, 0, BUFFER_SIZE); | |
| for (int count = 0; count < BUFFER_SIZE; ++count) | |
| { | |
| if (bufferExpected[count] != bufferActual[count]) |
jnm2