OT: PHP BCMath slowness
Mario Salzer
mario at erphesfurt.de
Fri Aug 5 02:29:56 PDT 2005
Kurt Raschke wrote:
> [...]
> content management system, and I am finding that BCMath seems to be
> extraordinarily slow for such things as Diffie-Hellman
> calculations...what takes BCMath 40-45 seconds is done by GMP in just a
> few seconds at most. I am not sure if it is even wise to include
PHPs bcmath extension uses the code from the GNU or BSD projects
implementation of the bc(1) or dc(1) utility.
These tools are used for arbitrary-_precision_ calculations, which
means mathematic calculations with many many numbers AFTER the
comma.
While it therefore could be used for bignum calculations as well,
this was not it's purpose and surely explains why it takes that
lengthy in comparison to GMP and other bignum implementations
(which cannot handle arbitrarily precise numbers). BCmath deals
with real numbers, while GMP only cares about integers.
On a Linux computer you can test it in a terminal/console by just
invoking 'bc'. The GNU projects bc(1) is however rarely compiled
in POSIX-compliant mode and therefore won't master powmod
calculations in the size DH requires. dc(1) still could.
mario
More information about the yadis
mailing list