VB optimization #349
NFITC1
started this conversation in
Improvement suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I cloned this repo and tested this theory and it works in debug mode.
The current PrimeBASIC/solution_2 has the line
primesArray(number \ 2)
twice possibly iterating several thousand times per calculation. I've discovered that doing a bit shift is up to 10 times faster and replacing both instances at lines 31 and 40 withprimesArray(number >> 1)
increased the pass count from ~545 to ~635 in debug mode on my machine. Functionally these statements are identical. I discovered years ago that VB was way better at bit-shifting than actual mathematical calculation. According to the rules of submission, is there any violation in this change?I also eked out another small optimization using a stopwatch object rather than the
(DateTime.utcnow - startTime
comparison for elapsed time bringing the average pass count to 673 (in debug mode).Beta Was this translation helpful? Give feedback.
All reactions