anup30 wrote: |
---|
why so big difference between outputs(passes count) of coliru & my pc! |
|
|
|
|
** Running time: 1000335838 ** Running time sec: 1 count per sec:472 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 |
Anything special about 8 at a time? |
DavesGarage wrote: |
---|
... may only use a single bit to represent a sieve element, which avoids people wastefully using bytes or even complete words to represent a number in the sieve. It also forces the language to do some bitwise math to access a sieve element, which exercises both the language and the compiler ... |
|
|
|
|
dhayden@DHAYDENHTZK3M2 ~/tmp $ g++ -O4 -o foo.exe foo.cxx dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9886 microseconds avg passes in 1 sce/score : 101.153 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9961 microseconds avg passes in 1 sce/score : 100.392 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 10056 microseconds avg passes in 1 sce/score : 99.4431 |
|
|
dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9195 microseconds avg passes in 1 sce/score : 108.755 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9790 microseconds avg passes in 1 sce/score : 102.145 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9941 microseconds avg passes in 1 sce/score : 100.594 |
|
|
dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 8789 microseconds avg passes in 1 sce/score : 113.779 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 10270 microseconds avg passes in 1 sce/score : 97.371 dhayden@DHAYDENHTZK3M2 ~/tmp $ ./foo n = 1000000 Time taken = 9101 microseconds avg passes in 1 sce/score : 109.878 |
|
|
total passes in 5 sce/score : 2787 total time = 5000343 microseconds primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, biggest prime in range: 999983 -------------------------------- Process exited after 5.018 seconds with return value 0 Press any key to continue . . . |
|
|
total passes in 5 sec/score : 218 total time = 5000334 microseconds primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, biggest prime in range: 999983 -------------------------------- Process exited after 5.021 seconds with return value 0 Press any key to continue . . . |
|
|
passes /score : 7724 total time = 5000334 microseconds first few primes = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 biggest prime in range = 999983 -------------------------------- Process exited after 5.011 seconds with return value 0 Press any key to continue . . . |
Ganado wrote: |
---|
Maybe try -O5 |