-
Notifications
You must be signed in to change notification settings - Fork 608
Precision checking algorithm is very slow #573
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
Comments
I believe the issue is just this for-loop, but I don't have a concrete suggestion for how to fix it. Maybe parallelize it with a multi-threaded queue? swift-snapshot-testing/Sources/SnapshotTesting/Snapshotting/UIImage.swift Lines 105 to 108 in 88f6e2c
|
FYI: There's a promising open PR (#571) that aims to address three issues involving that loop, including its surprisingly long execution time (when compiled without optimizations, as is default for "Debug" builds). |
Another option would be to move the image diff analysis from the CPU to the GPU. The problem solved by #571 could also be tackled by additionally running CIAreaMaximum to see whether any of the pixels is above a certain threshold. |
The use of CoreImage filters in #628 improves the speed by 90-97%: going from ~1s to ~2ms per snapshot. This is accomplished using the CILabDeltaE filter, but could also be done with a CIColorAbsoluteDifference to calculate the Euclidean color distance instead of a perceptual color difference. |
@ejensen I'm working on a few tests and the precision makes the tests super slow e.g a test takes 0.5s to complete but with Edit: It's faster if I also add a |
The speedup added in #628 was only enabled when |
Describe the bug
When snapshot testing images with precision lower than 1, if the snapshots don't exactly match the reference images, the tests take much longer to run.
We currently have 66 snapshot tests in a framework
Those 9 failing unit-tests are recording 4 images each to account for different device sizes, so those 36 images that are not pixel-perfect are responsible for a 12.7x increase in the total duration for running 66 unit tests. The recorded images are not very large, ranging from 81KB to 255KB.
To Reproduce
Set the precision to any value lower than 1 and modify the tested view so they're not pixel-perfect with the reference images anymore.
Expected behavior
Checking whether or not the snapshots are within the accepted precision should be faster. A 12.7x increase for just 36 images is a whole different order of magnitude.
Environment
The text was updated successfully, but these errors were encountered: