• A
    Improve performance of DateTime#seconds_since_unix_epoch · 822c858a
    Andrew White 提交于
    Calculate the seconds since the UNIX epoch using the difference in
    Julian day numbers from the epoch date. By reducing the Rational math
    to just the offset component this gives a significant improvement.
    
    Benchmark:
    
    Calculating --------------------------------------------
           new     27733 i/100ms
       current     15031 i/100ms
           new     27737 i/100ms
       current     15549 i/100ms
    --------------------------------------------------------
           new   548182.1 (±0.9%) i/s - 2745567 in 5.008943s
       current   216380.9 (±1.6%) i/s - 1082232 in 5.002781s
           new   510281.9 (±1.2%) i/s - 2551804 in 5.001525s
       current   219858.3 (±1.8%) i/s - 1103979 in 5.023039s
    822c858a
conversions.rb 3.3 KB