{"push_id":759241797,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"8ea5c5435285614121c62591d3632e87561b1f68","before":"48a941ebfd223b145e0dbf5a3a76912cfffedb82","commits":[{"sha":"8ea5c5435285614121c62591d3632e87561b1f68","author":{"email":"5e886fd8553a574c2402a51da3ad5965d4249ec1@gmail.com","name":"Anthony Clays"},"message":"Improve undigit perfomance, can specify base\nPerfomance gain of 2.5 by using an explicit for loop\nNot using functional constructs (which julia is currently not very good at optimizing) in undigit gives large perfomance gains, especially when using numbers with many digits.\nI tested two implementations:\n\nfunction undigit2(ds::Vector{Int}, base::Int = 10)\n    acc = 0\n    for digit in reverse(ds)\n        acc = base * acc + digit\n    end\n    acc::Int\nend\n\nfunction undigit3(ds::Vector{Int}, base::Int = 10)\n    acc = 0\n    for (i, digit) in enumerate(ds)\n        acc += digit * base ^ (i-1)\n    end\n    acc::Int\nend\n\nThe last implementation was more perfomant when profiling:\n\n@time for i in 1000000:10000000\n    @assert undigit2(digits(i)) == i\nend\n   3.021 seconds      (18000 k allocations: 2197 MB, 7.94% gc time)\n\n@time for i in 1000000:10000000\n    @assert undigit3(digits(i)) == i\nend\n   2.583 seconds      (18000 k allocations: 1236 MB, 6.28% gc time)","distinct":true,"url":"https://api.github.com/repos/anthonyclays/Digits.jl/commits/8ea5c5435285614121c62591d3632e87561b1f68"}]}