GMP vs BN
Torbjorn Granlund
tege at swox.com
Tue Mar 15 21:01:04 CET 2005
mts.spb.suxx at mail.ru writes:
Did anyone try to benchmark the GMP against the BigNum library from
the OpenSSL package?
Here are some results. I used the command "openssl speed rsa" to
get the OpenSSL numbers and a small home frown program for RSA to
get the GMP numbers.
Athlon 2.2 GHz (32-bit):
OpenSSL 0.9.7d sign verify sign/s verify/s
rsa 512 bits 0.0006s 0.0001s 1668.5 19312.4
rsa 1024 bits 0.0024s 0.0001s 410.8 8022.4
rsa 2048 bits 0.0130s 0.0004s 77.1 2690.4
rsa 4096 bits 0.0815s 0.0013s 12.3 797.9
GMP 4.1.4 sign verify sign/s verify/s
rsa 512 bits 0.00023s 0.00003s 4262.3 39428.0
rsa 1024 bits 0.00131s 0.00007s 764.2 14287.4
rsa 2048 bits 0.00822s 0.00022s 121.6 4448.7
rsa 4096 bits 0.05564s 0.00070s 18.0 1435.8
GMP is 2 to 2.5 times faster here.
Athlon 1.8 GHz (64-bit):
OpenSSL 0.9.7d sign verify sign/s verify/s
rsa 512 bits 0.0003s 0.0000s 3194.6 36893.6
rsa 1024 bits 0.0009s 0.0001s 1135.5 17194.5
rsa 2048 bits 0.0047s 0.0002s 213.9 6609.9
rsa 4096 bits 0.0288s 0.0005s 34.7 2158.1
GMP 4.1.4 sign verify sign/s verify/s
rsa 512 bits 0.00016s 0.00001s 6225.3 67309.0
rsa 1024 bits 0.00081s 0.00004s 1230.3 24074.8
rsa 2048 bits 0.00494s 0.00014s 202.5 7206.2
rsa 4096 bits 0.03373s 0.00049s 29.6 2037.2
Here OpenSSL actually beats GMP for 3 of the 8 tests. (Since GMP
lacks assembly loops for this platform, the compiler's performance
for the critical loops is crucial. I used GCC 3.4.2 with the
odd options -O2 -funroll-loops -mtune=nocona.
Pentium 4 (Northwood) 2.6 GHz:
OpenSSL 0.9.7d sign verify sign/s verify/s
rsa 512 bits 0.0009s 0.0001s 1147.5 12017.8
rsa 1024 bits 0.0042s 0.0002s 236.7 4317.9
rsa 2048 bits 0.0253s 0.0008s 39.5 1327.2
rsa 4096 bits 0.1689s 0.0026s 5.9 378.3
GMP 4.1.4 sign verify sign/s verify/s
rsa 512 bits 0.00028s 0.00003s 3529.2 29529.7
rsa 1024 bits 0.00164s 0.00009s 611.3 10630.4
rsa 2048 bits 0.01055s 0.00030s 94.8 3360.0
rsa 4096 bits 0.06883s 0.00096s 14.5 1042.5
Here the order is restored, GMP is around 3 times faster than
OpenSSL.
Alpha 21264 833 MHz:
OpenSSL 0.9.7e sign verify sign/s verify/s
rsa 512 bits 0.0007s 0.0001s 1416.0 15786.1
rsa 1024 bits 0.0022s 0.0001s 456.4 7431.2
rsa 2048 bits 0.0117s 0.0004s 85.3 2726.4
rsa 4096 bits 0.0725s 0.0012s 13.8 835.5
GMP 4.1.4 sign verify sign/s verify/s
rsa 512 bits 0.00031s 0.00003s 3185.7 33465.3
rsa 1024 bits 0.00141s 0.00007s 707.6 13452.9
rsa 2048 bits 0.00772s 0.00021s 129.5 4809.2
rsa 4096 bits 0.04662s 0.00065s 21.4 1548.2
Again, GMP outperforms OpenSSL. On average about twice
as fast.
This can continue with many platforms. On OpenSSL's home turf
(RSA), GMP 4.1.4 is usually between 2 and 3 times faster.
That factor will substantially increase in the future. :-)
--
Torbjörn
More information about the gmp-discuss
mailing list