kchapelier / node-mathp

Math utility for node
MIT License
9 stars 1 forks source link

Simplify chebyshev dist implementation #8

Closed megawac closed 9 years ago

kchapelier commented 9 years ago

Thanks for your contributions, do you mind if I credit you as a contributor in the package.json ?

On a more related note : http://jsperf.com/chebyshevdistancen

newImplementationVariant is basically the same as your implementation but with a single exit point. I usually try to avoid multiple exit points in functions, but the performance trade off of the multiple exit points is good (±9%). I'll apply the same change on other distanceN functions.

kchapelier commented 9 years ago

Got some unexpected results on other distanceN functions :

http://jsperf.com/mathp-manhattandistancen http://jsperf.com/mathp-minkowskidistancen http://jsperf.com/mathp-euclideandistancen

They'll stay with their single exit point for the moment

megawac commented 9 years ago

The perf will change again when you change binding (insert issue here) On Dec 21, 2014 7:17 AM, "Kevin Chapelier" notifications@github.com wrote:

Got some unexpected results on other distanceN functions :

http://jsperf.com/mathp-manhattandistancen http://jsperf.com/mathp-minkowskidistancen http://jsperf.com/mathp-euclideandistancen

They'll stay with their single exit point for the moment

— Reply to this email directly or view it on GitHub https://github.com/kchapelier/node-mathp/pull/8#issuecomment-67768598.