manuelbieh/geolib

isDecimal terrible performance

jonenst opened this issue · 4 comments

Hi,
using flamecharts to investigate the performance of getPathLength, I noticed that 80% of the time is spent in the isDecimal function. Replacing it with a faster version would improve performance by a factor of 3 or 4. See this codepen: https://codepen.io/jonenst/pen/OJyeeVN

when replacing the isDecimal function with "return true", the time to run the script goes from 6.5s to 2s: https://codepen.io/jonenst/pen/GRpbVry

Or the code could be restructured to offer unsafe versions of function that don't validate input if it's not possible to make it fast ?

Also the next bottleneck is the keys lookup for ["lat", "latitude", 1] and the same for longitude. Removing this reduces the time to 0.5s

Codepen entries give 404 now @jonenst

Doh, do they expire? Sorry, didn't know about that. It wasn't very complicated though, should be easy to reproduce.