Question

Decided to run a quick test to see how bcmath operates on various versions of PHP, and noticed that the latest and greatest is lacking significantly in speed when compared to 4.3,

I am wondering if anyone knows what the reason behind this is, and/or how the speed can be improved on 5+ so that it is reasonably comparable to 4.3.

Also note, the memory consumption from 5.6+ is triple that which 4.3 requires for the same operation :

Performance Test Results (Waterflow)

Was it helpful?

Solution

It's not faster. The graphs you see include not only the bcmath call, but the startup & shutdown overhead as well.

$start = microtime(true);
for ($i = 0; $i < 1000; ++$i) {
    bcdiv(40075036, 86164.098903691, 40);
}

echo microtime(true) - $start;

This snippet would measure the bcdiv performance: http://3v4l.org/unrRL

As you can see - the performance is pretty much the same.

A note: you can see that the numbers are really small, it means that you cannot completely trust them and you should understand that any additional load on the machine can affect the test results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top