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

Improve @turf/boolean-overlap performance on MultiPoints #1910

Merged
merged 1 commit into from Jun 16, 2020

Conversation

mfedderly
Copy link
Collaborator

Changes:

  • Don't make a copy of the multipoint coordinates
  • Exit early when we know there is an overlap, instead of continuing on
  • Removed some unused imports as a bonus

I wanted to try something similar on the lines and polygons, but segmentEach() doesn't have a way to exit early so I skipped it for now.

Here's the relevant bench.js output, I removed the ones for lines and polygons:

Before:

equal-multipoints: 0.271ms
multipoints: 0.231ms
multipoints: 0.025ms
single-multipoints: 0.021ms
equal-multipoints x 65,977 ops/sec ±1.40% (87 runs sampled)
multipoints x 1,664,734 ops/sec ±2.02% (83 runs sampled)
multipoints x 1,572,537 ops/sec ±1.52% (86 runs sampled)
single-multipoints x 1,860,378 ops/sec ±1.86% (89 runs sampled)

After:

equal-multipoints: 0.186ms
multipoints: 0.035ms
multipoints: 0.017ms
single-multipoints: 0.014ms
equal-multipoints x 69,743 ops/sec ±1.49% (88 runs sampled)
multipoints x 4,899,999 ops/sec ±1.88% (79 runs sampled)
multipoints x 5,212,289 ops/sec ±1.44% (79 runs sampled)
single-multipoints x 6,440,465 ops/sec ±1.53% (87 runs sampled)

@rowanwins rowanwins self-requested a review June 16, 2020 10:33
Copy link
Member

@rowanwins rowanwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@rowanwins rowanwins merged commit 9f151a5 into master Jun 16, 2020
@rowanwins rowanwins deleted the mf/boolean-overlap-perf branch June 16, 2020 10:34
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.

None yet

2 participants