Skip to content

Conversation

@tocsoft
Copy link
Member

@tocsoft tocsoft commented Dec 16, 2016

Think I managed to make a tiny perf boost to complex polygons... and i think I managed to same a little bit of memory in the process.

Method Mean StdDev Scaled Scaled-StdDev Gen 0 Gen 1 Gen 2 Allocated
'Complex Polygon - Master' 11.6810 ms 0.0674 ms 1.00 0.00 9422.9167 672.9167 672.9167 35.13 MB
'Complex Polygon - Updated' 6.6927 ms 0.2831 ms 0.57 0.02 706.2500 677.0833 677.0833 7.63 MB

Trying to avoid using clipper to merge polygons when they can be avoided.
Try to use the origional (potentially optermised shapes) if merging will produce not change the origional shape.

We do this in a couple of ways:
- We strip away any holes that don't intersect with an outline
- We skip merging outlines that dont intersect with any other shape and simple pass then through. This provides the added benefit/optimisation of using the specialised shapes instead of the generic polygon class where possible.
removed a Linq call from the critical path of geting distance from point.
@JimBobSquarePants
Copy link
Member

I'd say that's more than a tiny boost. Great stuff!

@JimBobSquarePants JimBobSquarePants merged commit a457381 into SixLabors:master Dec 17, 2016
@tocsoft tocsoft deleted the optimise-polygon-merging branch December 21, 2016 14:42
antonfirsov pushed a commit to antonfirsov/ImageSharp that referenced this pull request Nov 11, 2019
Optimise polygon merging in complex polygons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants