3v4l.org

run code in 300+ PHP versions simultaneously
<?php function run_test($name, $callback, $iterations) { $start = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = $callback(); } $stop = microtime(true); $delta = $stop - $start; echo "ran '$name' with result ", var_export($result, true), " in $delta msecs\n"; } class Foo { } class Bar { function setup() {} } $method1 = function($test) { return function () use ($test) { if (method_exists($test, 'setup')) { $test->setup(); } }; }; $method2 = function($test) { $func = method_exists($test, 'setup') ? function() use ($test) { $test->setup(); } : function () {}; return function () use ($func) { $func(); }; }; $method3 = function($test) { $test = method_exists($test, 'setup') ? [$test, 'setup'] : function () {}; return function () use ($test) { $test(); }; }; const ITERATIONS = 1000; run_test('foo1', $method1(new Foo()), ITERATIONS); run_test('bar1', $method1(new Bar()), ITERATIONS); run_test('foo2', $method2(new Foo()), ITERATIONS); run_test('bar2', $method2(new Bar()), ITERATIONS); run_test('foo3', $method3(new Foo()), ITERATIONS); run_test('bar3', $method3(new Bar()), ITERATIONS);

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.0030.01019.49
7.1.70.0040.00417.15
7.1.60.0100.01419.40
7.1.50.0070.01717.14
7.1.00.0000.05322.34
7.0.200.0000.00816.66
7.0.140.0000.07722.20
7.0.60.0030.04719.93
7.0.50.0030.08317.74
7.0.40.0000.08717.71
7.0.30.0070.08017.69
7.0.20.0100.08017.81
7.0.10.0030.09317.75
7.0.00.0170.07717.78
5.6.280.0030.07721.16
5.6.210.0070.09020.70
5.6.200.0170.07318.26
5.6.190.0070.08718.15
5.6.180.0070.08318.23
5.6.170.0030.04718.14
5.6.160.0070.05318.15
5.6.150.0000.05318.16
5.6.140.0170.07718.25
5.6.130.0100.08018.21
5.6.120.0030.08718.18
5.6.110.0100.07318.16
5.6.100.0070.07718.18
5.6.90.0170.06718.16
5.6.80.0030.08717.56
5.6.70.0070.06317.57
5.6.60.0130.07717.51
5.6.50.0070.08317.55
5.6.40.0030.06317.54
5.6.30.0100.07717.52
5.6.20.0070.07717.54
5.6.10.0100.06717.52
5.6.00.0070.06717.53
5.5.350.0270.07720.47
5.5.340.0030.08717.98
5.5.330.0030.08717.94
5.5.320.0030.05718.05
5.5.310.0030.05317.94
5.5.300.0100.08017.99
5.5.290.0070.08717.97
5.5.280.0100.08317.96
5.5.270.0100.07717.95
5.5.260.0100.07717.96
5.5.250.0200.07017.78
5.5.240.0070.08017.46
5.5.230.0030.07717.46
5.5.220.0100.07717.34
5.5.210.0130.06017.35
5.5.200.0000.05717.36
5.5.190.0070.06017.44
5.5.180.0100.07717.32
5.5.160.0130.07017.44
5.5.150.0070.06317.34
5.5.140.0030.08317.34
5.5.130.0070.06317.42
5.5.120.0100.05717.36
5.5.110.0130.03317.30
5.5.100.0130.06717.30
5.5.90.0070.08017.21
5.5.80.0100.06717.30
5.5.70.0100.08017.21
5.5.60.0030.07717.23
5.5.50.0030.07717.21
5.5.40.0030.04317.32
5.5.30.0070.08317.21
5.5.20.0070.08017.33
5.5.10.0100.05717.18
5.5.00.0070.04317.20
5.4.450.0070.08019.39
5.4.440.0100.08719.33
5.4.430.0070.05319.33
5.4.420.0070.04719.46
5.4.410.0070.08319.32
5.4.400.0000.07319.07
5.4.390.0030.08718.89
5.4.380.0100.07319.27
5.4.370.0200.06719.10
5.4.360.0170.05019.12
5.4.350.0070.04719.02
5.4.340.0100.07719.02
5.4.320.0070.06319.05
5.4.310.0030.06019.12
5.4.300.0070.05319.03
5.4.290.0070.03718.89
5.4.280.0030.08019.14
5.4.270.0030.08018.95
5.4.260.0100.04018.97
5.4.250.0030.05319.11
5.4.240.0070.08019.03
5.4.230.0100.07718.99
5.4.220.0030.09019.11
5.4.210.0100.06719.04
5.4.200.0100.08019.12
5.4.190.0000.08719.03
5.4.180.0030.05719.11
5.4.170.0070.05019.11
5.4.160.0030.05719.00
5.4.150.0100.05719.02
5.4.140.0070.08016.35
5.4.130.0170.06716.35
5.4.120.0070.05316.48
5.4.110.0030.06716.38
5.4.100.0030.08316.52
5.4.90.0200.06316.55
5.4.80.0100.06316.52
5.4.70.0030.07716.48
5.4.60.0000.07016.53
5.4.50.0100.06316.46
5.4.40.0000.07316.30
5.4.30.0100.06316.50
5.4.20.0100.07316.24
5.4.10.0100.07316.57
5.4.00.0070.07315.74
5.3.290.0100.06714.77
5.3.280.0030.07314.65
5.3.270.0070.07714.73
5.3.260.0070.07714.65
5.3.250.0100.06314.60
5.3.240.0100.07014.74
5.3.230.0030.08314.62
5.3.220.0030.07314.64
5.3.210.0030.04314.61
5.3.200.0100.07314.70
5.3.190.0070.07714.55
5.3.180.0030.05714.64
5.3.170.0030.08014.57
5.3.160.0070.07714.65
5.3.150.0000.08314.45
5.3.140.0030.08014.63
5.3.130.0030.06714.43
5.3.120.0070.07314.79
5.3.110.0070.07014.63
5.3.100.0070.07714.11
5.3.90.0030.05714.08
5.3.80.0030.08014.11
5.3.70.0030.07314.06
5.3.60.0070.07014.24
5.3.50.0030.08014.01
5.3.40.0100.07014.20
5.3.30.0000.08013.96
5.3.20.0070.04713.57
5.3.10.0070.04013.68
5.3.00.0100.04713.51
5.2.170.0000.06711.21
5.2.160.0030.03711.05
5.2.150.0070.06011.05
5.2.140.0000.06711.16
5.2.130.0030.06311.12
5.2.120.0000.04310.96
5.2.110.0100.05011.13
5.2.100.0070.05711.12
5.2.90.0100.05711.15
5.2.80.0030.04711.13
5.2.70.0000.07011.06
5.2.60.0030.06711.07
5.2.50.0000.04310.91
5.2.40.0030.06010.89
5.2.30.0030.06010.98
5.2.20.0070.05710.96
5.2.10.0070.05711.07
5.2.00.0100.04710.82
5.1.60.0030.05010.00
5.1.50.0130.04310.00
5.1.40.0030.0409.95
5.1.30.0100.05310.19
5.1.20.0030.05710.36
5.1.10.0070.04710.07
5.1.00.0000.05710.05
5.0.50.0100.0409.45
5.0.40.0070.0179.45
5.0.30.0100.0579.45
5.0.20.0000.0309.45
5.0.10.0030.0439.45
5.0.00.0030.0579.45
4.4.90.0030.0339.45
4.4.80.0030.0309.45
4.4.70.0030.0379.45
4.4.60.0000.0409.45
4.4.50.0000.0379.45
4.4.40.0030.0539.45
4.4.30.0000.0379.45
4.4.20.0000.0409.45
4.4.10.0000.0279.45
4.4.00.0030.0439.45
4.3.110.0000.0209.45
4.3.100.0000.0379.45
4.3.90.0100.0309.45
4.3.80.0070.0239.45
4.3.70.0000.0379.45
4.3.60.0070.0339.45
4.3.50.0030.0309.45
4.3.40.0000.0579.45
4.3.30.0000.0239.45
4.3.20.0000.0279.45
4.3.10.0000.0379.45
4.3.00.0000.0379.45

preferences:
38.06 ms | 401 KiB | 5 Q