3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(callable $fn, callable $decorator) { $wrapper = $decorator(); return function() use ($fn, $wrapper) { $gen = $wrapper(); // Only call the wrapped function if the decorator made "yield" if (!$gen instanceof \Generator) { return $gen; } // Use the yielded arguments, forward all if none given. if (is_array($gen->current())) { $arguments = $gen->current(); } else { $arguments = func_get_args(); } // Forward all throwed Exceptions try { // Send the decorated function's return value into the // decorator as return value of "yield" $gen->send(call_user_func_array($fn, $arguments)); } catch (\Exception $e) { $gen->throw($e); } }; } function foo($bar) { throw new Exception("Error $bar!"); } function catch_all_exceptions() { return function() { try { (yield); } catch (\Exception $e) { echo "catch_all_exceptions: Caught Exception: $e\n"; } }; } function do_something_before() { return function() { echo "Before!\n"; return "foo"; }; } $foo = decorate(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.0170.00316.50
8.3.50.0100.01017.22
8.3.40.0000.01518.88
8.3.30.0110.00418.64
8.3.20.0000.00818.77
8.3.10.0150.00420.53
8.3.00.0040.00419.38
8.2.180.0090.00616.48
8.2.170.0080.00822.96
8.2.160.0100.00721.02
8.2.150.0050.00324.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0000.00820.88
8.2.110.0100.00720.38
8.2.100.0040.00819.54
8.2.90.0110.00018.09
8.2.80.0070.00019.41
8.2.70.0050.00317.38
8.2.60.0060.00317.93
8.2.50.0080.00018.07
8.2.40.0040.00418.02
8.2.30.0040.00418.05
8.2.20.0030.00517.66
8.2.10.0040.00417.56
8.2.00.0030.00517.68
8.1.280.0070.00725.92
8.1.270.0080.00024.66
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0040.00422.02
8.1.230.0000.01021.03
8.1.220.0040.00417.74
8.1.210.0040.00418.84
8.1.200.0030.00617.35
8.1.190.0000.00717.41
8.1.180.0000.00918.10
8.1.170.0000.00818.79
8.1.160.0070.00018.78
8.1.150.0040.00418.71
8.1.140.0040.00417.47
8.1.130.0000.00817.77
8.1.120.0040.00417.41
8.1.110.0030.00517.37
8.1.100.0040.00417.44
8.1.90.0040.00417.46
8.1.80.0030.00317.48
8.1.70.0030.00317.40
8.1.60.0040.00417.55
8.1.50.0040.00417.45
8.1.40.0050.00517.46
8.1.30.0000.00717.70
8.1.20.0050.00317.61
8.1.10.0060.00317.45
8.1.00.0000.00717.56
8.0.300.0040.00420.16
8.0.290.0040.00416.63
8.0.280.0070.00018.46
8.0.270.0070.00017.27
8.0.260.0000.00716.82
8.0.250.0000.00817.01
8.0.240.0030.00316.98
8.0.230.0000.00717.01
8.0.220.0030.00516.98
8.0.210.0000.00716.82
8.0.200.0050.00317.07
8.0.190.0030.00316.98
8.0.180.0050.00517.03
8.0.170.0040.00416.98
8.0.160.0000.00816.98
8.0.150.0090.00016.94
8.0.140.0090.00316.96
8.0.130.0060.00013.44
8.0.120.0030.00516.96
8.0.110.0040.00416.99
8.0.100.0050.00316.86
8.0.90.0040.00417.07
8.0.80.0100.00716.95
8.0.70.0050.00317.02
8.0.60.0000.00717.09
8.0.50.0040.00416.82
8.0.30.0110.00817.23
8.0.20.0020.01717.19
8.0.10.0060.00317.21
8.0.00.0080.01316.83
7.4.330.0050.00012.98
7.4.320.0000.00716.52
7.4.300.0040.00416.51
7.4.290.0040.00416.51
7.4.280.0040.00316.64
7.4.270.0000.00816.55
7.4.260.0030.00313.19
7.4.250.0030.00616.58
7.4.240.0070.00016.53
7.4.230.0000.00616.50
7.4.220.0090.00916.55
7.4.210.0050.00916.57
7.4.200.0030.00516.46
7.4.190.0030.00316.75
7.4.160.0080.00816.36
7.4.150.0140.00316.68
7.4.140.0080.00916.56
7.4.130.0130.00316.61
7.4.120.0100.00716.63
7.4.110.0100.00716.54
7.4.100.0100.00716.65
7.4.90.0240.02216.56
7.4.80.0140.00519.39
7.4.70.0080.00816.47
7.4.60.0030.01316.47
7.4.50.0060.00216.59
7.4.40.0110.00716.39
7.4.30.0070.01016.43
7.4.10.0060.01015.07
7.4.00.0110.00615.04
7.3.330.0000.00613.26
7.3.320.0060.00013.45
7.3.310.0000.00716.40
7.3.300.0000.00716.35
7.3.290.0090.00916.38
7.3.280.0060.01216.38
7.3.270.0070.01016.34
7.3.260.0100.00716.41
7.3.250.0100.01116.40
7.3.240.0110.00516.29
7.3.230.0070.01116.52
7.3.210.0110.00716.55
7.3.200.0110.00616.50
7.3.190.0100.00616.58
7.3.180.0170.00316.45
7.3.170.0030.01316.39
7.3.160.0130.00316.66
7.3.130.0070.01315.16
7.3.120.0040.01214.97
7.3.110.0100.00814.80
7.3.100.0060.00714.93
7.3.90.0090.00314.77
7.3.80.0080.00714.67
7.3.70.0060.00714.71
7.3.60.0060.00814.61
7.3.50.0090.00514.72
7.3.40.0000.01014.85
7.3.30.0040.01014.88
7.3.20.0070.00716.56
7.3.10.0080.00916.76
7.3.00.0060.00916.73
7.2.330.0120.00616.77
7.2.320.0070.01116.85
7.2.310.0100.01316.41
7.2.300.0130.00516.49
7.2.290.0030.01716.80
7.2.260.0070.01314.73
7.2.250.0060.01315.08
7.2.240.0080.00814.90
7.2.230.0080.00815.10
7.2.220.0070.00614.94
7.2.210.0030.01015.00
7.2.200.0080.00815.06
7.2.190.0070.01215.10
7.2.180.0030.01314.89
7.2.170.0030.01214.83
7.2.160.0040.00714.97
7.2.150.0060.01216.62
7.2.140.0030.00916.86
7.2.130.0030.00916.75
7.2.120.0060.00817.00
7.2.110.0030.01016.70
7.2.100.0080.00416.88
7.2.90.0060.00617.04
7.2.80.0080.00817.01
7.2.70.0000.01316.81
7.2.60.0000.01417.04
7.2.50.0030.00817.05
7.2.40.0100.00317.07
7.2.30.0070.00316.97
7.2.20.0120.00316.66
7.2.10.0100.00317.06
7.2.00.0030.00818.03
7.1.330.0080.00615.79
7.1.320.0030.00815.77
7.1.310.0050.00815.92
7.1.300.0090.00515.80
7.1.290.0050.00915.69
7.1.280.0080.00715.77
7.1.270.0020.00815.70
7.1.260.0050.00715.61
7.1.250.0090.00615.80
7.1.240.0070.00715.63
7.1.230.0040.00815.74
7.1.220.0030.01015.75
7.1.210.0080.00315.80
7.1.200.0040.00415.87
7.1.190.0000.01115.65
7.1.180.0030.00615.62
7.1.170.0040.00815.57
7.1.160.0000.00815.85
7.1.150.0050.00515.72
7.1.140.0030.01015.88
7.1.130.0070.00315.87
7.1.120.0100.00315.91
7.1.110.0090.00615.82
7.1.100.0050.00416.79
7.1.90.0000.00915.75
7.1.80.0040.00815.61
7.1.70.0070.00516.51
7.1.60.0090.00717.63
7.1.50.0070.01016.27
7.1.40.0090.00915.67
7.1.30.0030.00915.71
7.1.20.0070.00715.82
7.1.10.0000.01715.85
7.1.00.0030.02019.13
7.0.330.0030.00615.57
7.0.320.0080.00315.31
7.0.310.0000.00915.54
7.0.300.0060.00615.51
7.0.290.0000.01015.22
7.0.280.0030.00715.30
7.0.270.0000.01115.35
7.0.260.0090.00315.53
7.0.250.0030.01015.61
7.0.240.0030.00715.59
7.0.230.0030.00915.57
7.0.220.0110.00015.59
7.0.210.0040.00815.50
7.0.200.0240.00815.22
7.0.190.0110.00015.50
7.0.180.0090.00915.37
7.0.170.0070.00715.48
7.0.160.0080.00815.57
7.0.150.0040.00815.38
7.0.140.0010.04018.56
7.0.130.0000.01015.50
7.0.120.0020.04218.61
7.0.110.0030.01015.20
7.0.100.0060.00615.46
7.0.90.0080.00815.40
7.0.80.0000.01715.47
7.0.70.0110.00415.14
7.0.60.0060.04317.54
7.0.50.0050.02916.63
7.0.40.0070.02816.87
7.0.30.0150.03016.71
7.0.20.0120.04116.87
7.0.10.0220.03516.71
7.0.00.0060.04816.77
5.6.400.0060.00614.49
5.6.390.0060.00914.16
5.6.380.0030.00614.48
5.6.370.0040.00714.60
5.6.360.0030.01014.49
5.6.350.0000.01714.39
5.6.340.0070.00314.23
5.6.330.0040.00814.35
5.6.320.0000.01414.71
5.6.310.0030.00614.61
5.6.300.0060.01014.14
5.6.290.0060.00914.06
5.6.280.0050.04017.77
5.6.270.0000.01214.47
5.6.260.0030.00614.41
5.6.250.0000.01714.25
5.6.240.0000.01314.24
5.6.230.0000.00814.10
5.6.220.0040.00814.45
5.6.210.0080.03017.38
5.6.200.0030.04616.34
5.6.190.0110.01817.65
5.6.180.0180.02117.44
5.6.170.0170.04217.53
5.6.160.0150.03717.45
5.6.150.0050.04516.26
5.6.140.0080.04316.38
5.6.130.0100.03716.35
5.6.120.0070.02317.63
5.6.110.0060.03817.80
5.6.100.0020.02717.60
5.6.90.0080.04217.78
5.6.80.0050.04017.24
5.6.70.0170.03817.40
5.6.60.0030.00914.36
5.6.50.0090.00614.16
5.6.40.0050.00514.20
5.6.30.0060.00314.23
5.6.20.0100.00314.38
5.6.10.0030.01014.28
5.6.00.0040.00914.27
5.5.380.0120.00314.51
5.5.370.0000.01514.50
5.5.360.0030.01014.15
5.5.350.0230.04017.48
5.5.340.0080.02716.13
5.5.330.0050.02517.28
5.5.320.0100.04217.32
5.5.310.0230.02517.32
5.5.300.0050.04316.21
5.5.290.0060.04516.12
5.5.280.0080.02217.68
5.5.270.0100.03817.78
5.5.260.0110.02217.59
5.5.250.0050.04317.34
5.5.240.0070.04017.20
5.5.230.0070.00314.33
5.5.220.0030.00614.21
5.5.210.0100.00714.27
5.5.200.0000.01514.12
5.5.190.0000.01214.15
5.5.180.0000.01414.35
5.5.170.0130.00314.01
5.5.160.0060.00614.07
5.5.150.0100.00314.21
5.5.140.0030.01014.21
5.5.130.0070.00714.48
5.5.120.0100.00614.40
5.5.110.0030.01513.93
5.5.100.0030.00814.48
5.5.90.0100.00314.27
5.5.80.0080.00514.36
5.5.70.0030.00714.43
5.5.60.0040.01414.08
5.5.50.0060.01014.24
5.5.40.0060.00314.36
5.5.30.0060.01014.34
5.5.20.0040.00814.07
5.5.10.0000.01214.01
5.5.00.0030.01014.16
5.4.450.0060.02615.28
5.4.440.0050.02815.37
5.4.430.0040.02315.28
5.4.420.0050.02515.20
5.4.410.0080.03015.18
5.4.400.0050.02415.04
5.4.390.0030.02414.79
5.4.380.0030.02215.07
5.4.370.0050.04115.12
5.4.360.0020.02515.06
5.4.350.0050.02115.02
5.4.340.0070.03615.13
5.4.330.0030.00811.03
5.4.320.0020.02414.98
5.4.310.0020.02415.01
5.4.300.0080.01815.21
5.4.290.0030.02214.97
5.4.280.0100.03715.06
5.4.270.0100.03514.91
5.4.260.0090.03514.92
5.4.250.0080.03314.86
5.4.240.0100.02315.08
5.4.230.0030.02915.22
5.4.220.0050.03414.82
5.4.210.0050.02115.06
5.4.200.0050.02015.12
5.4.190.0090.03914.97
5.4.180.0050.02914.92
5.4.170.0050.02214.89
5.4.160.0000.03215.10
5.4.150.0020.02414.78
5.4.140.0050.02813.67
5.4.130.0090.02413.63
5.4.120.0070.02513.66
5.4.110.0030.04113.80
5.4.100.0040.03013.88
5.4.90.0080.03013.72
5.4.80.0050.02313.66
5.4.70.0050.02813.79
5.4.60.0000.02713.64
5.4.50.0050.03113.47
5.4.40.0070.02813.63
5.4.30.0080.02313.68
5.4.20.0070.01713.54
5.4.10.0030.02013.54
5.4.00.0040.01813.27
5.3.290.0050.02012.71
5.3.280.0030.02712.49
5.3.270.0080.03512.64
5.3.260.0030.02012.44
5.3.250.0050.03712.53
5.3.240.0050.02812.49
5.3.230.0050.02812.53
5.3.220.0070.02312.42
5.3.210.0080.03812.52
5.3.200.0080.03812.53
5.3.190.0030.02512.43
5.3.180.0030.02812.61
5.3.170.0090.02712.51
5.3.160.0030.03312.62
5.3.150.0080.03712.48
5.3.140.0070.02912.63
5.3.130.0030.02312.47
5.3.120.0020.02412.51
5.3.110.0060.02012.55
5.3.100.0030.04212.31
5.3.90.0090.02012.38
5.3.80.0080.02712.21
5.3.70.0070.03112.20
5.3.60.0030.02412.34
5.3.50.0030.03812.20
5.3.40.0060.03812.21
5.3.30.0080.03712.14
5.3.20.0020.02912.02
5.3.10.0030.04211.99
5.3.00.0030.04311.94
5.2.170.0030.04011.29
5.2.160.0070.05711.14
5.2.150.0000.07011.06
5.2.140.0070.06311.19
5.2.130.0070.06011.06
5.2.120.0030.04011.15
5.2.110.0070.05711.10
5.2.100.0030.05311.25
5.2.90.0070.02711.16
5.2.80.0030.03311.18
5.2.70.0130.05311.04
5.2.60.0000.06011.07
5.2.50.0000.03310.93
5.2.40.0100.03311.00
5.2.30.0000.03711.01
5.2.20.0030.05711.11
5.2.10.0030.05710.79
5.2.00.0030.03710.68
5.1.60.0070.0479.90
5.1.50.0070.05010.02
5.1.40.0030.0339.95
5.1.30.0030.04710.34
5.1.20.0070.05710.24
5.1.10.0000.06010.13
5.1.00.0030.05310.02
5.0.50.0070.0478.63
5.0.40.0030.0408.56
5.0.30.0000.0378.27
5.0.20.0000.0238.20
5.0.10.0000.0438.23
5.0.00.0030.0408.22
4.4.90.0000.0378.01
4.4.80.0000.0408.01
4.4.70.0000.0408.01
4.4.60.0030.0308.01
4.4.50.0030.0378.01
4.4.40.0070.0378.01
4.4.30.0030.0278.01
4.4.20.0130.0238.01
4.4.10.0000.0238.01
4.4.00.0000.0538.01
4.3.110.0030.0338.01
4.3.100.0000.0208.01
4.3.90.0000.0278.01
4.3.80.0000.0408.01
4.3.70.0030.0338.01
4.3.60.0030.0378.01
4.3.50.0030.0208.01
4.3.40.0070.0278.01
4.3.30.0000.0178.01
4.3.20.0000.0208.01
4.3.10.0030.0308.01
4.3.00.0000.0378.01

preferences:
40.94 ms | 401 KiB | 5 Q