Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinaryDiff could be much faster #3193

Closed
matthiaskraaz opened this issue Sep 22, 2023 · 2 comments
Closed

BinaryDiff could be much faster #3193

matthiaskraaz opened this issue Sep 22, 2023 · 2 comments
Labels
type: improvement A general improvement
Milestone

Comments

@matthiaskraaz
Copy link
Contributor

matthiaskraaz commented Sep 22, 2023

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.

@joel-costigliola
Copy link
Member

Thanks for reporting this @matthiaskraaz, do you want to contribute the improvement ?

@matthiaskraaz
Copy link
Contributor Author

You mean, making a PR? I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A general improvement
Projects
None yet
3 participants