nordlow / gmp-d

D-language high-level wrapper for GNU MP (GMP) library
14 stars 6 forks source link

Speed Test gmp-d vs Bigint vs gmp vs rust-gmp ... #2

Closed andrew-m-h closed 6 years ago

andrew-m-h commented 7 years ago

So far, this is all talk. We need numbers to show people why they should use gmp-d over the other options. Can we beat rust-gmp? How much overhead is added on top of optimal gmp C code? How fast is gmp-d against the major competitor, Bigint?

andrew-m-h commented 7 years ago

After a cursory test using the Fermat Little Theorem test as an example, it appears that BigInt is a complete Joke in terms of performance when compared with gmp-d. It is also lacking some fundamental functions commonly used, such as pow_mod and root_rem. I implemented pow_mod in D for BigInt to give it a fighting chance, and it was too slow to actually complete the test on my computer. I think this is a great advertisment for a gmp binding for D.

nordlow commented 7 years ago

Any implementation that uses expression templates (ET) is gonna be faster (at run-time) than all the wrapper implementations that doesn't (including rust-gmp). Further, gmp-d operates, when possible, directly on the underlying __mpz__struct without the overhead of a __gmpz-function call. Compiled with LDC, gmp-d should beat everything except low-level C algorithms directly using the GMP C API. Remains to be proven though. Benchmarking examples are very welcome as I have little experience with which calculations that are most common and time-consuming in multi-precision-software.

nordlow commented 7 years ago

I've added some optimization to the operator overloads now.

nordlow commented 6 years ago

I'm closing this for now.