-
Notifications
You must be signed in to change notification settings - Fork 0
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
Optimising Sieve of Atkin by calculating instead of iterating. #118
Conversation
I am not convinced this has better performance. Are FP operations less expensive than loops? |
Bringing the branch up to date.
Dummy commit which I will revert later to see which implementation of the sieve of Atkin is faster.
I plotted histograms of the running times (in milliseconds) of constructing the sieve of Atkin up to 100,000,000 on the GitHub Actions runners. As seen in the details of the previous commit, this was done 10,000 times for both methods, starting with the older method. There were 1,000 histogram bins distributed equally in the range of values obtained with each method. (Note that this means the bins were different for the methods.)
|
Same graphs as above, but with the calculation performed first. (See the details of the previous commit.) |
Going to try to benchmark using Criterion.
Benchmarking with Criterion.rs reveals that constructing the sieve till 1,000,000 is faster with iteration than calculation. More analysis required! |
Loops have single-digit number of iterations, so iteration should be faster than calculation.
Constructing the sieve of Atkin up to 106 is faster on this branch than
|
For 105, this branch is slower.
|
For inputs 107, 108 and 109, there was no significant difference between calculation and iteration.
Closing. |
No description provided.