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

Python/Java Decimal Arithmetic Pi Benchmark

This benchmark compares the Python modules cdecimal.so, decimal.py and Java's BigDecimal class. Python's native binary float type and gmpy's binary mpf type are included for a better overview.

The benchmark runs 10000 iterations of calculating pi to various precisions.


64-bit Ubuntu, 3.16GHz Core 2 Duo

Python nativecdecimalgmpydecimal.pyJava BigDecimal
9 digits0.116s0.239s0.458s19.44s0.526s
19 digits-0.514s0.457s45.74s1.454s
38 digits-1.124s0.946s-5.678s
100 digits-3.855s3.039s-45.453s

32-bit Linux, 1.2GHz Celeron

Python nativecdecimalgmpydecimal.pyJava BigDecimal
9 digits0.447s2.921s4.607s104.49s2.83s
19 digits-6.440s4.591s246.67s15.14s
38 digits-15.449s9.588s-59.87s
100 digits-44.980s27.224s-464.71s


Python factorial benchmark for huge numbers

This benchmark compares the Python modules cdecimal.so and gmpy. Python's native integer type is included for a better overview.

The benchmark calculates the factorial of huge numbers. The timings are split into pure calculation time and conversion time to decimal string.

The factorial algorithm is chosen for comparison purposes. Faster algorithms are described here: Fast Factorial Functions


64-bit Ubuntu, 3.16GHz Core 2 Duo

Python nativecdecimalgmpy
100000!1.60s + 71.94s0.44s + 0.01s0.21s + 0.18s
1000000!76.24s + >2h7.62s + 0.07s3.15s + 6.51s
10000000!-94.60s + 0.85s50.07s + 165.67s

32-bit Linux, 1.2GHz Celeron, 512MB memory

Python nativecdecimalgmpy
100000!7.10s + 250.37s4.68s + 0.02s1.55s + 0.991s
1000000!-71.24s + 0.31ssegfault
10000000!-896.61s + 3.71s-


Contact:

Stefan Krah <website @ bytereef.org>