-
Notifications
You must be signed in to change notification settings - Fork 1
Performance test for isPrimeSearch
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) | ||
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 |
Searching from 100.000 to 200.000 (interval: 100.000)
| CheckForPrime1 (whl): 0.8063 | CheckForPrime1 (wsa): 0.7147 | CheckForPrime1 (for): 1.5279 |
| CheckForPrime2 (whl): 1.2418 | CheckForPrime2 (wsa): 1.1394 | CheckForPrime2 (for): 2.4082 |
| CheckForPrime3 (whl): 1.2275 | CheckForPrime3 (wsa): 1.1934 | CheckForPrime3 (for): 2.0835 |
| CheckForPrime4 (whl): 238.5757 | CheckForPrime4 (wsa): 248.4423 | CheckForPrime4 (for): 340.7217 |
| CheckForPrime5 (whl): 0.7796 | CheckForPrime5 (wsa): 1.0944 | CheckForPrime5 (for): 1.0462 |
| CheckForPrime6 (whl): 0.4709 | CheckForPrime6 (wsa): 1.0758 | CheckForPrime6 (for): 0.7892 |
Searching from 200.000 to 400.000 (interval: 200.000)
| CheckForPrime1 (whl): 1.3967 | CheckForPrime1 (wsa): 0.991 | CheckForPrime1 (for): 0.9844 |
| CheckForPrime2 (whl): 2.4884 | CheckForPrime2 (wsa): 1.4276 | CheckForPrime2 (for): 1.5029 |
| CheckForPrime3 (whl): 2.0627 | CheckForPrime3 (wsa): 1.4001 | CheckForPrime3 (for): 1.4561 |
| CheckForPrime4 (whl): 426.7062 | CheckForPrime4 (wsa): 372.8232 | CheckForPrime4 (for): 350.9704 |
| CheckForPrime5 (whl): 0.7277 | CheckForPrime5 (wsa): 0.6901 | CheckForPrime5 (for): 0.6733 |
| CheckForPrime6 (whl): 0.6428 | CheckForPrime6 (wsa): 0.5645 | CheckForPrime6 (for): 0.5591 |
Searching from 10.000.020.000 to 10.000.040.000 (interval: 20.000)
| CheckForPrime6 (whl): 4.7266 | CheckForPrime6 (wsa): 4.5539 | CheckForPrime6 (for): 4.567 |
Searching from 10.000.000.000 to 10.000.100.000 (interval: 100.000)
| CheckForPrime6 (whl): 23.1544 | CheckForPrime6 (wsa): 22.9244 | CheckForPrime6 (for): 22.6361 |
Searching from 0 to 1.000.000 (interval: 1.000.000)
| CheckForPrime6 (whl): 2.0672 | CheckForPrime6 (wsa): 1.8981 | CheckForPrime6 (for): 1.8986 |