Skip to content

Conversation

oscardssmith
Copy link
Member

heavily inspired by @trizen, but refactored a little to make it more reliable.

@oscardssmith
Copy link
Member Author

some benchmarks:

x = prod(nextprime(big(2)^30, i) for i in 1:2)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}())
  0.028354 seconds (1.13 M allocations: 22.163 MiB)
@time lenstrafactors!(x, Dict{BigInt,Int}())
  0.110741 seconds (1.65 M allocations: 30.821 MiB, 26.82% gc time)

x = prod(nextprime(big(2)^30, i) for i in 1:20)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}());
  0.830832 seconds (14.86 M allocations: 346.059 MiB, 21.69% gc time)
@time lenstrafactors!(x, Dict{BigInt,Int}());
  0.375128 seconds (3.62 M allocations: 114.038 MiB, 11.86% gc time)

x = prod(nextprime(big(2)^50, i) for i in 1:2)
@time lenstrafactors!(x, Dict{BigInt,Int}())
 18.921172 seconds (296.05 M allocations: 6.041 GiB, 14.56% gc time)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}())
  56.697309 seconds (1.12 G allocations: 21.651 GiB, 20.29% gc time)

These are the bad cases for ecm (when all the factors are of similar size). That said, ecm tends to do a bunch better for larger inputs, and for numbers with a few smaller factors. This implementation is not especially optimized, but I think it is a good baseline for future improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant