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 Performance by Avoiding Recalculating Constants #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luckylsk34
Copy link

In convertRadiansToDegrees and convertDegreesToRadians methods, we are creating BigDecimals of PI/180 and 180/PI. These values have high precision and BigDecimal is too slow. We move these into a static variable to avoid repeated creations.

This change nets us about 50-66% speedup. The following table contains the testing on my machine.

Index Total Operations(ops) Total Time(s) Speed(ops/s) Speedup
Default 5,000,000 92 5.43E+04 1.00
Moved to Static Variables 5,000,000 55 9.09E+04 1.67

@luckylsk34 luckylsk34 marked this pull request as ready for review April 12, 2023 20:32
@luckylsk34
Copy link
Author

@mikereedell Hi Mike, please review.

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.

1 participant