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;

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)
7.2.00.0130.03819.27
7.1.70.0070.03617.06
7.1.60.0030.08819.17
7.1.50.0030.08216.79
7.1.00.0000.06722.30
7.0.200.0030.04116.92
7.0.140.0100.12322.00
7.0.80.0100.09719.95
7.0.70.0100.12719.97
7.0.60.0200.12319.92
7.0.50.0100.13320.36
7.0.40.0100.12720.15
7.0.30.0030.13320.12
7.0.20.0070.13720.06
7.0.10.0130.11020.05
7.0.00.0030.08320.03
5.6.280.0030.19721.11
5.6.230.0170.17320.55
5.6.220.0070.16320.66
5.6.210.0030.20320.58
5.6.200.0100.21320.97
5.6.190.0100.17321.05
5.6.180.0330.18721.18
5.6.170.0030.15021.05
5.6.160.0000.21721.05
5.6.150.0100.17321.07
5.6.140.0130.20020.95
5.6.130.0170.19321.13
5.6.120.0130.15721.04
5.6.110.0070.18320.96
5.6.100.0030.19720.94
5.6.90.0170.20021.01
5.6.80.0070.16020.51
5.6.70.0000.14720.44
5.6.60.0070.14020.34
5.6.50.0100.22020.53
5.6.40.0030.19020.36
5.6.30.0070.13720.46
5.6.20.0100.19320.39
5.6.10.0030.21320.48
5.6.00.0030.22720.31
5.5.370.0070.18320.43
5.5.360.0070.21320.36
5.5.350.0200.19720.50
5.5.340.0030.21020.75
5.5.330.0100.19020.89
5.5.320.0100.18320.82
5.5.310.0130.17020.66
5.5.300.0170.21720.88
5.5.290.0030.22020.74
5.5.280.0130.14320.90
5.5.270.0170.20720.93
5.5.260.0170.20720.82
5.5.250.0100.16020.61
5.5.240.0000.20320.32
5.5.230.0130.18720.23
5.5.220.0070.21720.27
5.5.210.0070.14020.30
5.5.200.0030.21020.24
5.5.190.0030.19720.14
5.5.180.0070.14720.29
5.5.160.0030.22720.20
5.5.150.0070.19320.11
5.5.140.0100.15020.12
5.5.130.0100.17320.00
5.5.120.0200.18720.20
5.5.110.0100.20020.25
5.5.100.0070.15320.19
5.5.90.0100.17719.99
5.5.80.0030.19720.03
5.5.70.0130.14320.08
5.5.60.0070.17720.09
5.5.50.0070.15320.07
5.5.40.0170.18320.08
5.5.30.0070.18719.95
5.5.20.0130.18320.15
5.5.10.0030.20020.14
5.5.00.0030.14020.03
5.4.450.0200.17719.41
5.4.440.0100.19719.37
5.4.430.0100.19319.33
5.4.420.0130.19019.35
5.4.410.0130.20319.07
5.4.400.0130.20019.08
5.4.390.0100.18718.95
5.4.380.0100.20319.21
5.4.370.0030.21319.18
5.4.360.0070.20718.85
5.4.350.0130.17319.09
5.4.340.0030.20719.21
5.4.320.0070.18719.04
5.4.310.0030.17319.03
5.4.300.0030.17019.20
5.4.290.0100.19019.03
5.4.280.0100.14718.88
5.4.270.0070.20719.12
5.4.260.0100.19019.10
5.4.250.0130.19718.90
5.4.240.0030.18718.92
5.4.230.0100.19719.18
5.4.220.0100.19719.19
5.4.210.0100.16019.04
5.4.200.0130.16318.94
5.4.190.0100.17019.20
5.4.180.0070.13319.12
5.4.170.0100.18018.94
5.4.160.0070.13318.88
5.4.150.0070.21018.88
5.4.140.0100.18716.47
5.4.130.0070.13716.46
5.4.120.0100.18316.30
5.4.110.0030.17716.55
5.4.100.0130.17316.40
5.4.90.0030.16316.52
5.4.80.0070.19016.47
5.4.70.0070.14316.43
5.4.60.0100.14716.30
5.4.50.0000.14316.29
5.4.40.0030.12716.30
5.4.30.0000.13716.29
5.4.20.0070.14316.36
5.4.10.0070.16316.32
5.4.00.0070.12315.78
5.3.290.0000.23014.67
5.3.280.0100.24314.68
5.3.270.0070.23014.72
5.3.260.0130.22014.59
5.3.250.0070.22014.55
5.3.240.0000.18014.55
5.3.230.0030.18314.73
5.3.220.0070.25314.53
5.3.210.0000.18014.54
5.3.200.0130.22314.69
5.3.190.0030.17314.59
5.3.180.0070.21314.53
5.3.170.0030.17714.64
5.3.160.0000.18014.65
5.3.150.0000.20714.67
5.3.140.0000.18314.71
5.3.130.0030.21014.50
5.3.120.0030.34014.66
5.3.110.0070.16014.68
5.3.100.0130.21314.09
5.3.90.0100.20014.07
5.3.80.0030.21014.18
5.3.70.0030.15314.09
5.3.60.0000.17714.11
5.3.50.0000.20014.00
5.3.40.0000.15313.99
5.3.30.0030.17314.01
5.3.20.0000.14313.73
5.3.10.0070.21013.64
5.3.00.0030.23013.66
5.2.170.0030.15312.00
5.2.160.0000.13012.00
5.2.150.0030.17712.00
5.2.140.0030.12712.00
5.2.130.0000.16012.00
5.2.120.0030.19712.00
5.2.110.0000.23312.00
5.2.100.0100.19312.00
5.2.90.0000.21312.00
5.2.80.0100.21012.00
5.2.70.0070.21312.00
5.2.60.0100.19012.00
5.2.50.0070.19012.00
5.2.40.0000.17312.00
5.2.30.0000.18712.00
5.2.20.0130.22312.00
5.2.10.0070.20312.00
5.2.00.0100.22012.00
5.1.60.0070.21012.00
5.1.50.0070.15012.00
5.1.40.0070.22012.00
5.1.30.0030.23012.00
5.1.20.0030.18312.00
5.1.10.0070.14712.00
5.1.00.0030.05712.00
5.0.50.0030.25712.00
5.0.40.0030.25712.00
5.0.30.0130.29312.00
5.0.20.0000.24712.00
5.0.10.0030.24712.00
5.0.00.0100.30012.00
4.4.90.0030.03012.00
4.4.80.0030.03712.00
4.4.70.0000.02712.00
4.4.60.0070.02312.00
4.4.50.0070.03012.00
4.4.40.0030.04012.00
4.4.30.0070.03012.00
4.4.20.0000.02312.00
4.4.10.0070.03312.00
4.4.00.0000.03012.00
4.3.110.0030.01312.00
4.3.100.0100.02712.00
4.3.90.0070.03012.00
4.3.80.0000.05712.00
4.3.70.0030.03012.00
4.3.60.0000.02712.00
4.3.50.0030.03312.00
4.3.40.0000.05312.00
4.3.30.0000.02012.00
4.3.20.0130.03312.00
4.3.10.0000.04012.00
4.3.00.0000.01712.00

preferences:
35.75 ms | 401 KiB | 5 Q