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

refactor: use stdlib_base_fmod instead of built-in in math/base/special/gcd #2815

Merged
merged 68 commits into from
Aug 29, 2024

Conversation

gunjjoshi
Copy link
Member

Description

What is the purpose of this pull request?

This pull request:

Related Issues

Does this pull request have any related issues?

None.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

I've changed the js implementation as well, to use our fmod instead of its % operator, so that both the implementations are close enough.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Aug 20, 2024
@gunjjoshi gunjjoshi marked this pull request as draft August 20, 2024 15:37
@gunjjoshi
Copy link
Member Author

As discussed, I generated benchmark results before and after making the changes proposed in this PR.

Before:

benchmark.js:

TAP version 13
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.202160416
  rate: 49465667.89811117
  ...
ok 1 benchmark finished
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.200456208
  rate: 49886207.565095715
  ...
ok 2 benchmark finished
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.200792958
  rate: 49802543.37405598
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok

benchmark.native.js:

TAP version 13
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.446446833
  rate: 22399083.74487226
  ...
ok 1 benchmark finished
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.442721583
  rate: 22587559.278762337
  ...
ok 2 benchmark finished
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.452107708
  rate: 22118623.113587793
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok

After:

benchmark.js:

TAP version 13
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.205398375
  rate: 48685876.89654312
  ...
ok 1 benchmark finished
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.202361708
  rate: 49416463.711602986
  ...
ok 2 benchmark finished
# @stdlib/math/base/special/gcd
  ---
  iterations: 10000000
  elapsed: 0.207460667
  rate: 48201908.075423285
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok

benchmark.native.js:

TAP version 13
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.435659958
  rate: 22953681.687679913
  ...
ok 1 benchmark finished
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.433399375
  rate: 23073406.601013213
  ...
ok 2 benchmark finished
# @stdlib/math/base/special/gcd::native
  ---
  iterations: 10000000
  elapsed: 0.438695959
  rate: 22794830.43973058
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok

@gunjjoshi
Copy link
Member Author

Looks like while the addon performance has improved, the performance of javascript became slower. Only changing the C implementation could be a possible way.

@kgryte
Copy link
Member

kgryte commented Aug 20, 2024

@gunjjoshi Yes, I think only using fmod in the C implementation is the path forward here.

Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Aug 24, 2024
@Planeshifter Planeshifter merged commit 1288e7e into stdlib-js:develop Aug 29, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Math Issue or pull request specific to math functionality. Ready To Merge A pull request which is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants