为什么php 4.3中的bcmath比php 5+快得多?

为什么php 4.3中的bcmath比php 5+快得多?

问题描述:

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)

决定运行快速测试,了解 bcmath code>如何在各种版本的PHP上运行, 并且注意到与4.3相比,最新和最大的速度显着缺乏速度。 p>

我想知道是否有人知道这背后的原因是什么,和/或速度如何提高 在5+以上,它与4.3的合理可比性。 p>

另请注意,5.6+的内存消耗是同一操作所需的4.3的三倍: p> \ n

性能测试结果(水流) p> div>

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.