Quick benchmark on PHPNG and HHVM

I performed a quick (and dirty) benchmark on a recent build of PHP7 and HHVM. PHP7 is performing a lot better than older versions but HHVM is still performing a lot faster. This benchmark is pure for fun and is in no way scientific 😉

PHPNG

Rasmus Lerdorf has made a vagrant box with a recent build of PHP 7 that can be cloned and ran with vagrant up. The benchmark script I ran is stored in /home/vagrant/php-src/Zend/bench.php. Be aware that there are two versions of php7 in the box. The normal php command is the debug version and is slower than the php7 command.

vagrant@php7dev:~/php-src$ php7 Zend/bench.php 
simple             0.062
simplecall         0.016
simpleucall        0.032
simpleudcall       0.032
mandel             0.212
mandel2            0.202
ackermann(7)       0.032
ary(50000)         0.005
ary2(50000)        0.004
ary3(2000)         0.079
fibo(30)           0.114
hash1(50000)       0.015
hash2(500)         0.014
heapsort(20000)    0.041
matrix(20)         0.043
nestedloop(12)     0.110
sieve(30)          0.019
strcat(200000)     0.006
------------------------
Total              1.039

So a total of 1.039 seconds is needed to run the benchmark. For comparison PHP 5.3 took 3.018, PHP 5.4 2.359, PHP 5.5 2.200 and finally PHP 5.6 2.190 so there is a trend downward.

HHVM

On the same machine (in a different virtual machine) I ran the same benchmark with HHVM and it finished in 0.451 seconds. That’s a remarkable difference! The gap between HHVM and PHPNG is getting smaller but still an improvement of almost 50%.

vagrant@vagrant-ubuntu-trusty-64:~/php-src/Zend$ php bench.php 
simple             0.012
simplecall         0.005
simpleucall        0.009
simpleudcall       0.010
mandel             0.031
mandel2            0.029
ackermann(7)       0.021
ary(50000)         0.012
ary2(50000)        0.018
ary3(2000)         0.076
fibo(30)           0.023
hash1(50000)       0.047
hash2(500)         0.021
heapsort(20000)    0.050
matrix(20)         0.031
nestedloop(12)     0.027
sieve(30)          0.020
strcat(200000)     0.008
------------------------
Total              0.451

So HHVM is still faster than PHP.net but PHP 7 is a large improvement on PHP 5 so it looks promising. Both runtimes are in constant development and a lot is happening on the PHP front.