3v4l.org

run code in 300+ PHP versions simultaneously
<?php // If this would be for real, decorators would directly replace // the decorated functions/methods. function decorate(callable $fn, array $decorators) { foreach ($decorators as $d) { $wrapper = $d($fn); $fn = $wrapper; } return $wrapper; } function foo($bar) { throw new Exception("Error $bar!"); } function catch_all_exceptions(callable $fn) { return function() use ($fn) { try { return call_user_func_array($fn, func_get_args()); } catch (\Exception $e) { echo "catch_all_exceptions: Caught Exception: $e\n"; } }; } function once(callable $fn) { return function() use ($fn) { static $return; static $called = false; if (!$called) { $return = call_user_func_array($fn, func_get_args()); $called = true; } return $return; }; } function do_something_before(callable $fn) { return function() use ($fn) { echo "Before!\n"; return call_user_func_array($fn, func_get_args()); }; } $bar = decorate(function() { echo "Hello\n"; }, ["once"]); $bar(); $bar(); $bar(); $foo = decorate("foo", ["catch_all_exceptions", "do_something_before"]); var_dump($foo("bar"));

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)
8.3.60.0210.00016.50
8.3.50.0120.00817.35
8.3.40.0070.00718.79
8.3.30.0060.01018.89
8.3.20.0100.00018.73
8.3.10.0040.00420.66
8.3.00.0000.00817.63
8.2.180.0140.00716.63
8.2.170.0110.00422.96
8.2.160.0030.01022.08
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0040.00419.83
8.2.110.0070.00420.75
8.2.100.0120.00017.72
8.2.90.0090.00019.10
8.2.80.0090.00018.05
8.2.70.0030.00717.63
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0040.00418.22
8.2.30.0080.00018.01
8.2.20.0040.00417.66
8.2.10.0040.00617.70
8.2.00.0050.00317.84
8.1.280.0100.00325.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00022.53
8.1.230.0040.00721.03
8.1.220.0030.00618.77
8.1.210.0040.00418.95
8.1.200.0060.00317.47
8.1.190.0020.00517.52
8.1.180.0030.00518.10
8.1.170.0030.00518.90
8.1.160.0000.00718.98
8.1.150.0050.00218.57
8.1.140.0040.00417.38
8.1.130.0000.00717.77
8.1.120.0080.00017.45
8.1.110.0040.00417.44
8.1.100.0000.00717.44
8.1.90.0050.00217.45
8.1.80.0020.00517.43
8.1.70.0000.00817.48
8.1.60.0030.00517.62
8.1.50.0000.00817.36
8.1.40.0040.00417.45
8.1.30.0000.00817.49
8.1.20.0060.00317.52
8.1.10.0050.00317.49
8.1.00.0060.00317.51
8.0.300.0030.00619.95
8.0.290.0000.00716.88
8.0.280.0030.00318.46
8.0.270.0070.00017.29
8.0.260.0000.00716.89
8.0.250.0070.00016.91
8.0.240.0070.00317.05
8.0.230.0030.00316.93
8.0.220.0000.00817.04
8.0.210.0080.00016.85
8.0.200.0000.00916.95
8.0.190.0040.00417.08
8.0.180.0070.00017.05
8.0.170.0030.00716.99
8.0.160.0000.00717.04
8.0.150.0040.00416.88
8.0.140.0080.00016.96
8.0.130.0030.00313.45
8.0.120.0040.00416.97
8.0.110.0000.00816.88
8.0.100.0080.00016.80
8.0.90.0000.00716.93
8.0.80.0070.00716.92
8.0.70.0040.00416.95
8.0.60.0040.00417.03
8.0.50.0000.00716.78
8.0.30.0110.00817.12
8.0.20.0090.00917.06
8.0.10.0040.00417.17
8.0.00.0070.01417.10
7.4.330.0000.00513.07
7.4.320.0030.00316.55
7.4.300.0000.00616.44
7.4.290.0030.00316.52
7.4.280.0040.00416.55
7.4.270.0040.00416.55
7.4.260.0000.00713.28
7.4.250.0040.00416.60
7.4.240.0050.00316.44
7.4.230.0000.00716.34
7.4.220.0230.00316.50
7.4.210.0050.01116.56
7.4.200.0070.00016.52
7.4.190.0000.00716.47
7.4.160.0100.00616.45
7.4.150.0060.01216.59
7.4.140.0140.00516.63
7.4.130.0100.00716.42
7.4.120.0100.00816.51
7.4.110.0120.00616.54
7.4.100.0030.01416.63
7.4.90.0120.00616.60
7.4.80.0120.00616.47
7.4.70.0110.00616.49
7.4.60.0130.00716.45
7.4.50.0000.00916.50
7.4.40.0080.00816.44
7.4.30.0040.01816.42
7.4.00.0070.01115.00
7.3.330.0060.00013.31
7.3.320.0030.00313.31
7.3.310.0050.00316.32
7.3.300.0000.00716.41
7.3.290.0070.01116.47
7.3.280.0120.00616.48
7.3.270.0070.01116.40
7.3.260.0100.00816.55
7.3.250.0060.01216.44
7.3.240.0100.01016.43
7.3.230.0130.00316.65
7.3.210.0160.00316.64
7.3.200.0070.01119.39
7.3.190.0110.01116.65
7.3.180.0070.01116.46
7.3.170.0110.00516.53
7.3.160.0060.00916.35
7.3.120.0070.00714.75
7.2.330.0110.00716.48
7.2.320.0080.00816.55
7.2.310.0220.01316.62
7.2.300.0070.01016.70
7.2.290.0060.01216.64
7.2.60.0070.00716.60
7.2.00.0060.00619.42
7.1.200.0110.00315.86
7.1.100.0000.00817.78
7.1.70.0060.00917.12
7.1.60.0140.01019.40
7.1.50.0140.01016.64
7.1.00.0100.07022.33
7.0.200.0270.00714.67
7.0.140.0070.07322.21
7.0.120.0030.07322.09
7.0.60.0030.07319.93
7.0.50.0070.05717.90
7.0.40.0130.03720.40
7.0.30.0570.05020.10
7.0.20.0330.05320.09
7.0.10.0100.08020.15
7.0.00.0070.04020.13
5.6.280.0030.07721.10
5.6.210.0100.08720.50
5.6.200.0070.06718.18
5.6.190.0130.08020.58
5.6.180.2770.04720.61
5.6.170.0230.04020.38
5.6.160.0100.04720.55
5.6.150.0130.04718.27
5.6.140.0070.05018.22
5.6.130.0100.07718.14
5.6.120.0130.07321.14
5.6.110.0200.07020.89
5.6.100.0170.07720.91
5.6.90.0130.08321.00
5.6.80.0030.03720.43
5.6.70.4470.03320.37
5.5.350.0300.07320.43
5.5.340.0100.07717.91
5.5.330.0130.03320.36
5.5.320.0270.05020.31
5.5.310.0330.04020.32
5.5.300.0000.09017.99
5.5.290.0100.07017.99
5.5.280.0130.07720.80
5.5.270.0070.08320.66
5.5.260.0100.08020.91
5.5.250.0070.08020.61
5.5.240.0130.05320.14
5.4.450.0170.04019.47
5.4.440.0100.04019.25
5.4.430.0070.07719.33
5.4.420.0000.05019.47
5.4.410.0070.05019.32
5.4.400.0030.04019.25
5.4.390.0100.08319.15
5.4.380.0030.08019.24
5.4.370.0100.07318.84
5.4.360.0070.07019.12
5.4.350.0100.07019.18
5.4.340.0070.06318.86
5.4.320.0100.07718.84
5.4.310.0100.07319.25
5.4.300.0130.04319.24
5.4.290.0070.03718.84
5.4.280.0070.08019.16
5.4.270.0030.05018.99
5.4.260.0170.06318.98
5.4.250.0030.04019.24
5.4.240.0070.05719.07
5.4.230.0030.05319.02
5.4.220.0070.04319.00
5.4.210.0070.07318.92
5.4.200.0030.04319.20
5.4.190.0130.06718.86
5.4.180.0030.07719.13
5.4.170.0030.08719.26
5.4.160.0070.06719.22
5.4.150.0070.06019.10
5.4.140.0030.03716.55
5.4.130.0070.07016.34
5.4.120.0000.05016.51
5.4.110.0030.06316.48
5.4.100.0000.04016.48
5.4.90.0070.03316.48
5.4.80.0000.07716.59
5.4.70.0130.03716.41
5.4.60.0100.07016.48
5.4.50.0000.04716.36
5.4.40.0070.03716.27
5.4.30.0030.07316.36
5.4.20.0070.03716.42
5.4.10.0100.03316.64
5.4.00.0030.03715.79
5.3.290.0000.08314.71
5.3.280.0030.04014.68
5.3.270.0130.07314.63
5.3.260.0130.06714.64
5.3.250.0100.04314.71
5.3.240.0030.07014.68
5.3.230.0000.05014.57
5.3.220.0030.05314.76
5.3.210.0170.07014.76
5.3.200.0030.07714.63
5.3.190.0030.04014.65
5.3.180.0070.05714.59
5.3.170.0030.06714.63
5.3.160.0070.07314.59
5.3.150.0070.07314.60
5.3.140.0030.04714.65
5.3.130.0130.06314.59
5.3.120.0070.05714.63
5.3.110.0030.07314.63
5.3.100.0070.04014.10
5.3.90.0030.06714.12
5.3.80.0070.07314.05
5.3.70.0100.03314.22
5.3.60.0100.06714.05
5.3.50.0100.07014.05
5.3.40.0030.04014.02
5.3.30.0030.04713.94
5.3.20.0030.07013.70
5.3.10.0030.04313.70
5.3.00.0030.04013.70
5.2.170.0100.05711.20
5.2.160.0070.04011.21
5.2.150.0030.06311.10
5.2.140.0030.03311.20
5.2.130.0100.02711.11
5.2.120.0030.06011.16
5.2.110.0000.06311.11
5.2.100.0000.03311.10
5.2.90.0070.06011.25
5.2.80.0030.03710.98
5.2.70.0030.05711.11
5.2.60.0030.04711.20
5.2.50.0000.06011.04
5.2.40.0070.06010.96
5.2.30.0070.06010.94
5.2.20.0070.03711.01
5.2.10.0100.05710.92
5.2.00.0030.03010.77
5.1.60.0000.04010.16
5.1.50.0070.05010.05
5.1.40.0030.0539.98
5.1.30.0030.05710.34
5.1.20.0030.04710.37
5.1.10.0100.05010.22
5.1.00.0030.03310.14
5.0.50.0030.0238.61
5.0.40.0030.0238.32
5.0.30.0100.0308.23
5.0.20.0000.0478.27
5.0.10.0070.0408.19
5.0.00.0070.0538.14
4.4.90.0030.0377.79
4.4.80.0000.0377.79
4.4.70.0000.0407.79
4.4.60.0000.0207.79
4.4.50.0070.0137.79
4.4.40.0000.0277.79
4.4.30.0000.0237.79
4.4.20.0030.0207.79
4.4.10.0100.0137.79
4.4.00.0000.0407.79
4.3.110.0030.0207.79
4.3.100.0000.0377.79
4.3.90.0070.0237.79
4.3.80.0000.0437.79
4.3.70.0030.0337.79
4.3.60.0030.0207.79
4.3.50.0000.0307.79
4.3.40.0070.0507.79
4.3.30.0000.0407.79
4.3.20.0070.0237.79
4.3.10.0000.0277.79
4.3.00.0070.0277.79

preferences:
33.25 ms | 401 KiB | 5 Q