org.assertj.core.internal.BinaryDiff could be much faster
- assertj core version: 3.24.2
- java version: Java 11
- test framework version: JUnit 5
Test case reproducing the bug
Path expected = ...
Path actual = ...
assertThat(actual).hasSameBinaryContentAs(expected);
Solution
Change implementation as follows:
public BinaryDiffResult diff(Path actual, byte[] expected) throws IOException {
try(InputStream actualStream = new BufferedInputStream(Files.newInputStream(actual))) {
return diff(actualStream, expected);
}
}
(add BufferedInputStream)
Resulting speedup for 2,5MB: from 8 sec down to 0.2 sec.
org.assertj.core.internal.BinaryDiff could be much faster
Test case reproducing the bug
Solution
Change implementation as follows:
(add BufferedInputStream)
Resulting speedup for 2,5MB: from 8 sec down to 0.2 sec.