[Issue 4125] std.numeric.gcd can use a binary GCD

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 7 18:04:31 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=4125



--- Comment #6 from bearophile_hugs at eml.cc 2014-01-07 18:04:17 PST ---
Created an attachment (id=1313)
Faster GCD

Code for a binary GCD that on LDC2 is about twice faster on uint values, and
it's rather faster with dmd too.

Timings ("gcd" is the Phobos one):

DMD 2.061alpha (32 bit):
              gcd, time = 1924
    gcd_recursive, time = 1937
gcd_iterative_sub, time = 2931
gcd_iterative_mod, time = 1948
       gcd_binary, time = 3357
   gcd_binary_mod, time = 2136
     gcd_binary_2, time = 1406
     gcd_binary_2, time = 1391
Results sum: 1284258816


LDC2 (32 bit):
              gcd, time = 1930
    gcd_recursive, time = 1924
gcd_iterative_sub, time = 3148
gcd_iterative_mod, time = 1926
       gcd_binary, time = 2635
   gcd_binary_mod, time = 2036
     gcd_binary_2, time = 1461
     gcd_binary_3, time = 1026
Results sum: 1284258816

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list