So far I am enjoying nim. I have a personal benchmark that I try on each new 
language that I try. It uses the Pollard Rho algorithm to find a factor or 
2^257 - 1. I am using linux mint and a Ryzen 5600x cpu slightly overclocked 
(Geekbench single core score of 1730).

For my nim runs I use:
    `nim c -d:release --passC:-flto --passL:-s --gc:markAndSweep rho.nim`

The algorithm iterates 3790200 times and produces a factor of 535006138814359

Using the BigInt library: 106.3 seconds Using the BigNum library: 1.38 seconds 
Using the OCaml language with zarith: 1.2 seconds Using the F# language : about 
15 seconds

BigInt allows coding that closely follows the algorithm: `x = (x*x + c) mod n # 
all variables are BigInts`

BigNum is less readable, but acceptable to me: `x = `mod`(x ,add(t2, 
mul(t1,x,x), c), n)` or `discard `mod`(x ,add(t2, mul(t1,x,x), c), n)`

I find the discard statement ugly and the alternative only adds about .01 
seconds to the run. t1 and t2 are BigInt temporary variables that are not used 
since add and mul produce a return value.

So my conclusion is the BigInt is not suitable for problems of the rho type 
with big numbers to factor, but is very readable and suitable for less 
intensive problems. 

Reply via email to