[win32] ImageDataProvider getBounds performance #2564
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the performance of
Image#getBoundsif anImageDataProvideris used and no matching handle exists yet. This only affects the windows implementation.Reason for the worse performance is that currently multiple
ImageDatainstances plus an image handle instance is created and cleaned up for the operation, although one call toImageDataProvider#getImageDatawould be sufficient.How to test
Add an big image (at least 1000x1000 pixels) named "bigimage.png" so it can be found by the snippet and execute the snippet below with and without this PR und you'll see something similar to
Without PR:
Duration ImageDataProvider 3216 ms size: Rectangle {0, 0, 2000, 2000}
Duration ImageFileNameProvider 1668 ms size: Rectangle {0, 0, 2000, 2000}
With PR:
Duration ImageDataProvider 369 ms size: Rectangle {0, 0, 2000, 2000}
Duration ImageFileNameProvider 1547 ms size: Rectangle {0, 0, 2000, 2000}
For
ImageDataProviderperformance is drastically improved, forImageFileNameProviderit stays similar. But I think adapting the existing common implementation forgetBoundsmakes more sense as long is it does not have a negative effect.