3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function dynamicMethod($a) { return $a + 1; } public static function staticMethod($a) { return $a + 1; } public function __invoke($a) { return $a + 1; } } $object = new Test(); ///////////////////////// $function = function ($a) { return $a + 1; }; function testFunction($a) { return $a + 1; } // env //echo phpversion(), " ", PHP_OS, PHP_EOL; // dynamic $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object->dynamicMethod($i); } echo "dyn: ", microtime(true) - $startTime, PHP_EOL; // dynamic call_user_func $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = call_user_func_array(array($object, 'dynamicMethod'), array($i)); } echo "call_user_func: ", microtime(true) - $startTime, PHP_EOL; // static $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = Test::staticMethod($i); } echo "static: ", microtime(true) - $startTime, PHP_EOL; // invoke $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object($i); } echo "invoke: ", microtime(true) - $startTime, PHP_EOL; // function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = testFunction($i); } echo "func: ", microtime(true) - $startTime, PHP_EOL; // anonymous function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $function($i); } echo "anon: ", microtime(true) - $startTime, PHP_EOL;<?php

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.270.0090.04312.41
5.4.260.0080.04512.41
5.4.250.0070.04512.41
5.4.240.0070.05212.41
5.4.230.0070.05112.41
5.4.220.0110.04512.40
5.4.210.0100.04012.41
5.4.200.0040.04612.40
5.4.190.0080.04112.40
5.4.180.0070.04312.40
5.4.170.0060.04312.41
5.4.160.0080.03612.40
5.4.150.0070.03812.40
5.4.140.0070.04712.09
5.4.130.0070.04112.07
5.4.120.0060.03512.04
5.4.110.0060.03512.04
5.4.100.0080.03612.03
5.4.90.0090.03512.03
5.4.80.0050.03812.03
5.4.70.0060.03412.03
5.4.60.0080.03412.03
5.4.50.0090.03612.02
5.4.40.0040.04012.01
5.4.30.0040.03712.01
5.4.20.0070.03412.00
5.4.10.0040.03612.01
5.4.00.0060.03611.50
5.3.280.0070.03912.71
5.3.270.0090.03812.72
5.3.260.0070.03912.72
5.3.250.0070.03612.72
5.3.240.0060.03712.72
5.3.230.0070.03712.71
5.3.220.0070.03612.68
5.3.210.0070.03812.68
5.3.200.0070.03512.68
5.3.190.0050.03912.68
5.3.180.0080.04412.67
5.3.170.0090.05012.67
5.3.160.0100.04912.67
5.3.150.0070.04712.68
5.3.140.0070.03812.66
5.3.130.0090.03812.66
5.3.120.0070.03912.65
5.3.110.0040.04412.66
5.3.100.0060.04012.13
5.3.90.0050.04212.10
5.3.80.0060.03812.10
5.3.70.0040.03912.10
5.3.60.0070.03612.08
5.3.50.0070.04612.02
5.3.40.0040.04412.02
5.3.30.0050.04111.98
5.3.20.0050.04411.77
5.3.10.0090.04411.73
5.3.00.0080.04511.72

preferences:
142.25 ms | 1398 KiB | 8 Q