`UPDATE`, mostly more tweaking of `proc twins_sieve`. Tried different loop 
structures|idioms to see what would be faster (`for` vs `while` loops mostly, 
etc). Made some cosmetic, line order changes. Code `version 2108/04/05` more 
compact, a little more cleaner, with little more clearer comments than `version 
2018/04/03`.

[https://gist.github.com/jzakiya/6c7e1868bd749a6b1add62e3e3b2341e](https://gist.github.com/jzakiya/6c7e1868bd749a6b1add62e3e3b2341e)

Biggest change was compiling source in VB (Virtual Box) image of base OS 
distros which has `gcc 7.3.0`. Compiled source in it to create binary, then ran 
binary on base hardware (I7, 8 threads, 16GB mem) to a|b compare with previous 
version compiled using `gcc 4.9.2`. With gcc 4.9.2 the binary is 264,158 bytes, 
with gcc 7.3.0 it's 255,720 bytes. Not only was binary smaller, performance 
with gcc 7.3.0 was discernibly faster. Times are given below for tests done on 
`quiet` system.
    
    
    Input Number |   twinprimes   | twinprimes_ssoz  | twinprimes_ssoz  |  
primesieve
                 |                | 4/5/18 gcc 7.3.0 | 4/3/18 gcc 4.9.2 |
    
------------------------------------------------------------------------------------
    1e10         |     27,412,679 |       0.453      |     0.458        |      
0.572
    5e10         |    118,903,682 |       2.487      |     2.501        |      
3.112
    1e11         |    224,376,048 |       4.831      |     5.110        |      
6.475
    5e11         |    986,222,314 |      27.445      |    28.583        |     
35.675
    1e12         |  1,870,585,220 |      59.018      |    61.236        |     
75.638
    2e12         |  3,552,770,943 |     131.861      |   135.701        |    
162.975
    3e12         |  5,173,760,785 |     218.947      |   223.803        |    
252.175
    4e12         |  6,756,832,076 |     302.756      |   316.653        |    
354.066
    5e12         |  8,312,493,003 |     391.850      |   400.375        |    
448.066
    6e12         |  9,846,842,484 |     486.707      |   497.222        |    
547.792
    7e12         | 11,363,874,338 |     583.041      |   595.554        |    
642.447
    8e12         | 12,866,256,870 |     673.436      |   698.129        |    
749.884
    9e12         | 14,356,002,120 |     766.572      |   809.974        |    
843.042
    1e13         | 15,834,664,872 |     880.372      |   903.161        |    
953.423
    5e13         | 71,018,282,471 |    6341.153      |  6396.903        |
    

Reply via email to