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.1.70.0000.04217.26
7.1.60.0140.07819.82
7.1.50.0070.07317.02
7.1.00.0000.13322.42
7.0.200.0070.04916.43
7.0.140.0030.13022.00
7.0.60.0100.13019.95
7.0.50.0030.14017.91
7.0.40.0070.10720.11
7.0.30.0230.14320.28
7.0.20.0300.10320.06
7.0.10.0230.08020.03
7.0.00.0170.12020.20
5.6.280.0070.20720.84
5.6.210.0100.20320.48
5.6.200.0070.18318.22
5.6.190.0100.20020.57
5.6.180.0030.18320.62
5.6.170.0430.17020.54
5.6.160.0000.21320.56
5.6.150.0030.18318.25
5.6.140.0070.16318.18
5.6.130.0130.19018.27
5.6.120.0100.20721.01
5.6.110.0200.20721.11
5.6.100.0100.21021.15
5.6.90.0100.21021.02
5.6.80.0130.18020.53
5.6.70.0130.16020.55
5.5.350.0000.20720.37
5.5.340.0100.20317.96
5.5.330.0170.20320.25
5.5.320.0200.15320.38
5.5.310.0300.19020.23
5.5.300.0070.17718.04
5.5.290.0030.18017.97
5.5.280.0030.22020.90
5.5.270.0030.16020.89
5.5.260.0100.20720.79
5.5.250.0030.21720.60
5.5.240.0000.15020.21
5.4.450.0300.17319.18
5.4.440.0930.16319.39
5.4.430.0700.18019.54
5.4.420.0470.12319.31
5.4.410.0100.25019.04
5.4.400.0170.19318.80
5.4.390.0030.21018.60
5.4.380.0200.19318.60
5.4.370.0270.20718.73
5.4.360.0430.18718.70
5.4.350.0230.21318.68
5.4.340.0200.20718.67
5.4.320.0060.15412.52
5.4.310.0060.15512.52
5.4.300.0120.14912.52
5.4.290.0090.14612.52
5.4.280.0080.14712.42
5.4.270.0100.16412.42
5.4.260.0060.15512.41
5.4.250.0080.14912.41
5.4.240.0060.14712.41
5.4.230.0080.16112.41
5.4.220.0070.17912.41
5.4.210.0050.15012.40
5.4.200.0100.14912.41
5.4.190.0100.14812.40
5.4.180.0070.15612.40
5.4.170.0150.17912.39
5.4.160.0200.21412.39
5.4.150.0250.26912.39
5.4.140.0180.18412.07
5.4.130.0160.19012.06
5.4.120.0190.17712.02
5.4.110.0190.18512.01
5.4.100.0210.24412.02
5.4.90.0170.19012.02
5.4.80.0200.25312.01
5.4.70.0240.24212.01
5.4.60.0180.25212.01
5.4.50.0210.18012.00
5.4.40.0210.19211.99
5.4.30.0250.25011.98
5.4.20.0170.24611.99
5.4.10.0150.19511.98
5.4.00.0200.17711.48
5.3.290.0060.17512.80
5.3.280.0050.17412.71
5.3.270.0200.21912.72
5.3.260.0200.23212.71
5.3.250.0210.25912.72
5.3.240.0220.20912.72
5.3.230.0170.20812.71
5.3.220.0240.27212.68
5.3.210.0160.22112.68
5.3.200.0180.20512.68
5.3.190.0180.21512.68
5.3.180.0190.28212.67
5.3.170.0170.21012.67
5.3.160.0210.21612.67
5.3.150.0170.24512.67
5.3.140.0220.26412.66
5.3.130.0150.21112.66
5.3.120.0170.20612.66
5.3.110.0210.23712.66
5.3.100.0210.28812.14
5.3.90.0150.23012.12
5.3.80.0190.23512.11
5.3.70.0330.27012.11
5.3.60.0270.26912.10
5.3.50.0160.21712.04
5.3.40.0190.20812.04
5.3.30.0220.26512.01
5.3.20.0180.23011.79
5.3.10.0160.20811.75
5.3.00.0180.21111.73
5.2.170.0140.0379.22
5.2.160.0130.0379.21
5.2.150.0110.0409.22
5.2.140.0170.0369.21
5.2.130.0120.0379.18
5.2.120.0170.0319.17
5.2.110.0170.0349.18
5.2.100.0130.0359.19
5.2.90.0120.0349.18
5.2.80.0080.0409.17
5.2.70.0120.0359.18
5.2.60.0160.0319.13
5.2.50.0200.0589.09
5.2.40.0130.0369.07
5.2.30.0160.0349.05
5.2.20.0150.0339.05
5.2.10.0130.0338.95
5.2.00.0070.0398.80
5.1.60.0100.0318.09
5.1.50.0150.0268.08
5.1.40.0090.0338.07
5.1.30.0250.0818.42
5.1.20.0150.0298.45
5.1.10.0140.0288.17
5.1.00.0130.0298.16
5.0.50.0130.0236.65
5.0.40.0100.0266.50
5.0.30.0100.0366.31
5.0.20.0110.0216.28
5.0.10.0100.0226.26
5.0.00.0070.0386.25
4.4.90.0370.0494.78
4.4.80.0060.0194.75
4.4.70.0080.0204.76
4.4.60.0090.0164.76
4.4.50.0060.0194.77
4.4.40.0080.0584.71
4.4.30.0100.0174.76
4.4.20.0040.0224.84
4.4.10.0080.0174.85
4.4.00.0090.0284.76
4.3.110.0130.0434.67
4.3.100.0110.0144.66
4.3.90.0070.0184.63
4.3.80.0040.0304.58
4.3.70.0070.0194.63
4.3.60.0090.0174.63
4.3.50.0060.0204.63
4.3.40.0070.0274.54
4.3.30.0030.0203.31
4.3.20.0080.0163.29
4.3.10.0050.0183.25
4.3.00.0370.01715.13

preferences:
38.86 ms | 400 KiB | 5 Q