back to index
libmpdec
decimal benchmarks
multi precision benchmarks
Python/Java benchmarks

Benchmark against other arbitrary precision arithmetic libraries

This benchmark compares libmpdec, apfloat and mpfr. Both libmpdec and apfloat use a power of ten base, so it is no surprise that mpfr leads every benchmark with respect to pure calculation time [1]. However, when the result of a large calculation needs to be converted to decimal, libmpdec and apfloat are faster. To show this, the multiplication benchmarks have been split into calculation + conversion time. All other benchmarks are calculation time only.


64-bit Ubuntu, 3.16GHz Core 2 Duo, compiled with 64 bit libs

func/prec/iterlibmpdecapfloatmpfr
mul/5000/10.00s + 0.00s0.00s + 0.00s0.00s + 0.00s
mul/100000/10.02s + 0.00s0.01s + 0.01s0.01s + 0.02s
mul/1000000/10.14s + 0.03s0.19s + 0.03s0.04s + 0.75s
mul/10000000/12.32s + 0.26s2.96s + 0.35s0.64s + 17.44s
mul/100000000/120.59s + 2.65s32.59s + 3.40s8.56s + 328.59s
div/5000/10.01s0.00s0.00s
div/100000/10.04s0.05s0.02s
div/1000000/10.62s0.51s0.16s
div/10000000/17.59s7.91s2.85s
div/100000000/175.98s88.64s49.14s
sqrt/9/1000000.18s-0.01s
sqrt/19/1000000.26s-0.01s
sqrt/38/1000000.36s0.72s0.02s
sqrt/1000000/11.59s[2]0.82s0.13s
sqrt/10000000/122.50s12.67s2.31s
invroot/1000000/10.62s0.64s0.11s
invroot/10000000/18.44s9.79s1.54s
exp/9/1000000.73s-0.45s
exp/19/1000001.21s-0.65s
exp/38/1000002.16s70.96s[3]1.71s
exp/5000/11.04s0.62s0.01s
ln/9/1000001.27s-0.25s
ln/19/1000002.00s-0.28s
ln/38/1000003.30s20.90s[3]0.48s
ln/5000/12.25s0.20s0.01s

[1] mpfr also uses very clever algorithms.
[2] 1.39s without overhead for correctly rounded square root
[3] apfloat's exp and ln algorithms are optimized for very large numbers.

Contact:

Stefan Krah <website @ bytereef.org>