-
Notifications
You must be signed in to change notification settings - Fork 1
Performance test for isPrimeSearch
Dann Bleeker Pedersen edited this page Aug 31, 2019
·
18 revisions
whl – used a while loop to loop over all the numbers in the interval
wsa – used a while loop to loop over all the numbers in the interval, but added a skip-ahead if a prime is found, since no two primes bigger than 3 is next to each other
for – used a for loop to loop over all the numbers in the interval
Note that CheckForPrime6 is the best algorithm, however, there is not really a better solution for whl, wsa or for. More testing is needed.
**Searching from 200 to 400 (interval: 200)
While | While skip ahead | For |
—- | —- | —- |
CheckForPrime1 (whl): 0.0011 | CheckForPrime1 (wsa): 0.0006 | CheckForPrime1 (for): 0.0005 |
CheckForPrime2 (whl): 0.0006 | CheckForPrime2 (wsa): 0.0004 | CheckForPrime2 (for): 0.0003 |
CheckForPrime3 (whl): 0.0006 | CheckForPrime3 (wsa): 0.0003 | CheckForPrime3 (for): 0.0003 |
CheckForPrime4 (whl): 0.001 | CheckForPrime4 (wsa): 0.0006 | CheckForPrime4 (for): 0.0005 |
CheckForPrime5 (whl): 0.0002 | CheckForPrime5 (wsa): 0.0002 | CheckForPrime5 (for): 0.0001 |
CheckForPrime6 (whl): 0.0002 | CheckForPrime6 (wsa): 0.0002 | CheckForPrime6 (for): 0.0001 |