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

Don't compute sin, cos twice for the same angle #7

Merged
merged 2 commits into from
Jun 25, 2021

Conversation

pelmenstar1
Copy link
Contributor

@pelmenstar1 pelmenstar1 commented Jun 18, 2021

There are few cases in code where exprensive functions are called twice for the same angle. Newer runtimes are able to optimize such cases and speed of my version and current one will be the same. But older runtimes cannot do that.

Benchmarks:

In drawTicks (Benchmark):

  • Fly FS504 (API 21):
    current - 1 655 ns
    new - 677 ns
  • ZTE Blade V9 (API 27)
    current - 426 ns
    new - 198 ns

In differenceBetweenAngles (Benchmark):

  • Fly FS504 (API 21):
    current - 2 982 ns
    new - 1 830 ns
  • ZTE Blade V9 (API 27):
    current - 436 ns
    new - 425 ns

As you can see, newer runtime optimized differenceBetweenAngles and speed is almost the same

@Droppers
Copy link
Owner

Thank you for your contributions!

@Droppers Droppers merged commit 993d84a into Droppers:main Jun 25, 2021
@pelmenstar1 pelmenstar1 deleted the sin-cos-twice branch June 29, 2021 10:25
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.

None yet

2 participants