bigint-benchmark-rs
Benchmarks for Rust big integer implementations.
All benchmarks are run on Intel(R) Xeon(R) w7-3565X. We may benchmark more platforms in the future. Please open an issue if you
want to have another platform added.
Each benchmark is run 5 times, with the calculation repeated for at least 10 seconds each time. The fastest attempt is used as the result.
Libraries
| malachite | 0.14.0 | LGPL 3.0 | Derived from GMP and FLINT. Pure Rust, no_std |
| rug | 1.30.0 | LGPL 3.0 | Links to GMP |
| dashu | 0.4.2 | MIT or Apache 2.0 | Fork of ibig. Pure Rust, no_std |
| num-bigint | 0.4.6 | MIT or Apache 2.0 | Pure Rust, no_std |
| ibig | 0.3.6 | MIT or Apache 2.0 | Pure Rust, no_std |
Results
| malachite | 0.008 | 0.130 | 1.854 | 0.154 | 2.071 | 0.242 |
| rug | 0.008 | 0.146 | 2.440 | 0.165 | 2.782 | 0.483 |
| dashu | 0.019 | 0.497 | 10.324 | 0.609 | 14.500 | 2.798 |
| num-bigint | 0.019 | 0.582 | 18.261 | 0.741 | 23.821 | 5.430 |
| ibig | 0.019 | 0.602 | 19.094 | 0.759 | 25.171 | 5.193 |
Times in seconds.
Usage
Calculate 100 digits of e and compare answers:
$ bigint-benchmark --task e --lib ibig --lib num-bigint --lib rug --lib malachite --lib dashu -n 100 print
answer = 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427
ibig agrees
num-bigint agrees
rug agrees
malachite agrees
dashu agrees
Calculate the 500-th Fibonacci number and compare answers:
$ bigint-benchmark --task fib --lib ibig --lib num-bigint --lib rug --lib malachite --lib dashu -n 500 print
answer = 139423224561697880139724382870407283950070256587697307264108962948325571622863290691557658876222521294125
ibig agrees
num-bigint agrees
rug agrees
malachite agrees
dashu agrees
Benchmark calculating a million digits of e:
$ bigint-benchmark --task e --lib ibig --lib num-bigint --lib rug --lib malachite --lib dashu -n 1000000 benchmark
Tasks
e | n digits of e | Hard | Binary splitting | addition, multiplication, division, exponentiation, base conversion |
fib | n-th Fibonnaci number | Medium | Matrix exponentiation | addition, multiplication, base conversion |
fib_hex | n-th Fibonnaci number in hex | Easy | Matrix exponentiation | addition, multiplication |