L.LatLngBounds.extend optimization#2380
Conversation
|
Thanks for the pull! So the main performance win here is calling factories later and 2 times less checks for extending bounds, right? |
|
Yes, and the removing of Math.max and Math.min has also improved it a bit. |
|
I just remember trying to optimize by removing Math.min/max calls (in some other code) and then coming to conclusion that it makes almost no difference. But maybe I'm wrong. Generally we'd need to find a compromise between performance and simplicity/readability/terseness of the code for this to get into core. |
|
I updated jperfs page and the Math.min/max version is in green : The biggest difference is with Internet Explorer. For the other browsers, it something like 10-15% slower. Do you want a pull request with the Math.min/max version ? |
|
This is a significant performance pit when using markerclusterer. I'd love this to be pulled into 0.8. |
|
@danzel ^^ |
|
Yep, I like this :) We use extend A LOT in MarkerCluster. |
|
I saw your re-factoring on JsPerf with properties checks instead of instanceof checks. I opted for instanceof because it's faster on iOS7 and equivalent with a desktop computer :-) |
|
Cool, yeah I just wanted to check for myself :) |
|
OK, going to make an attempt at simplifying this a bit soon and then merge. |
There was a problem hiding this comment.
Getting back to this pull now... This else block means that the 10 lines of code below will never get executed, right?
|
OK, managed to simplify the code a bit with 665e766 and merged manually: https://github.com/Leaflet/Leaflet/commits/master Thanks again, great work! |
|
Awesome, next release is going to be intense! |
|
@danzel wanna measure perf improvement in MarkerCluster? |
|
Will do Monday when I'm on a real PC |
|
Oh, thanks for the merge. I'm happy to know I have 20 lines of code in this wonderful project :-) |
|
Still a nice improvement. |


Hello
I'm working on a KD-Tree MarkerCluster and the analysis of performances showed that L.LatLngBounds.extend
was the second most costly operation. So I optimized it, and… the code is less beautiful :(
Anyway, you have this pull-request.
And this is the result, the pull request contains the orange version : (Other is Internet Explorer 11)
JSPerfs