Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
colgate_total
· 3y ago · 0 comments
Another optimization would be to compare square of distance instead of distance, saving "Math.sqrt" call each iteration.
Comments
[–]
geraldwhen
3y ago
Math.sqrt in a big loop is surprisingly slow. You learn this 0.2 seconds into game development, but I ran into it in a business context recently.
3% of a large cpu intensive runtime was sqrt.
[–]
piotrjaw
3y ago
Damn, this is a great point, thank you!
[–]
piotrjaw
3y ago
I've actually added this to the article, thank you again!