glayzzle/php-runtime

Benchmark results with php7

Closed this issue · 3 comments

Something goes wrong, the performance gap between PHP & nodejs is too big.

Actual results from a VM ubuntu 16, 4 vCore :

NodeJS results :

317811
Duration 0.017sec

Hello world

Starting: 2017-01-26 21:07:27
End: 2017-01-26 21:07:27
Duration : 0.472 sec
-------------------
node -v
v7.0.0

PHP results :

php -f test/fibo.php 
317811
Duration 1.732sec
Hello world
------------------------------
php -f test/loop.php 
Starting: 2017-01-26 21:11:13
End: 2017-01-26 21:11:46
Duration : 33.655 sec
-------------------------------
php -v
PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

Hi @nikic,

As you are strong in PHP internals I would be grateful if you could give me a little help. In this benchmark (mainly Nodejs vs PHP) the Fibonacci results may be normal but for the loop tests it's very strange.

I've make a mistake in writing the loop in php ?

nikic commented

You are benchmarking with xdebug enabled, which will slow down execution a lot.

Everything goes well now 👍 - I think the benchmark on loops may not be fair because I don't handle global scoped variables.

devbox@devbox:~/Documents/glayzzle/php-runtime$ php -f test/fibo.php 
317811
Duration 0.067sec
Hello world

devbox@devbox:~/Documents/glayzzle/php-runtime$ php -f test/loop.php 
Starting: 2017-01-26 21:56:00
End: 2017-01-26 21:56:06
Duration : 5.643 sec

devbox@devbox:~/Documents/glayzzle/php-runtime$ php -v
PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies

Really thanks for your quick reply, and sorry to disturb for a so obvious bug.