-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Image comparison is extremely slow when running in a Jest environment #4972
Comments
If I remove the assertion, your repro passes in 3-5 seconds for me. I don't think this is jest's fault |
Have you tried to profile this and identify where it gets slow? |
@SimenB @thymikee I've made some tweaks to my test repo that illustrate something weird is going on with Jest. I took the
For good measure I also wrote a script using only Node that does the screenshot comparison and writes the diff to a file; it only takes about four seconds. So the slowdown seems to be writing a file within the Jest context. |
I'll close this because it is unlikely that there is a bug in Jest based on the conversation but please keep discussing here to resolve your issue if you like. |
@cpojer I know that I mentioned |
@cpojer I feel like I have some further evidence that Jest is doing something weird here and that maybe the ticket should not be closed. If you see the console timings after the Jest test runs they are about the same as when running the exact same code in just a Node script. But it seems as though Jest is just not finishing the test for another twenty seconds. |
I'm happy to reopen and appreciate your investigation. It would be awesome if you could find the root cause and propose a PR to fix it for everyone :) |
@cpojer If you get a moment could you take a peak at the for loop here that is wrapped inside of two |
Fascinating. This might be a case of the Meanwhile, I encourage you to build a custom test environment in Jest that pulls in this module in the parent context, which will probably be faster (assuming my intuition is correct that the code is deoptimized because of the |
Ok, that's really odd then :( I'm not sure right now what is causing the issue. |
I made a new issue after isolating the slowdown to just a call to Math. You can follow the new list of instructions here to reproduce the issue. Calling I'm going to close this ticket in favor of the aforementioned new one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm using
Jest
with jest-image-snapshot to create and diff image screenshots taken with puppeteer. When running a simple test the image comparison causes the test to take close to thirty seconds. I also wrote a Jest test withoutjest-image-snapshot
that instead uses Resemble for the image comparison and it takes about ten seconds; running the same screenshot and comparison outside of Jest in a script only takes 3-4 seconds. Something seems to be causing a heavily degraded performance for at least the task of comparing image data in Jest. I initially created this issue on thejest-image-snapshot
repo, but after realizing that the same degradation occurs when using a different image comparison library a suggestion was made to create a ticket here.OS: macOS High Sierra 10.13.1
Jest: 21.2.1
Node: 8.9.1
NPM: 5.5.1
Here is a repo to reproduce the issue.
The text was updated successfully, but these errors were encountered: