3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(array $decorators, callable $fn, array $arguments = array()) { foreach (array_reverse($decorators) as $decorator) { if (is_callable($decorator)) { $fn = $decorator($fn); } } return call_user_func_array($fn, $arguments); } function expects(/* $type,... */) { $types = func_get_args(); $decorator = function(callable $fn) use ($types) { $wrapper = function() use ($fn, $types) { foreach (func_get_args() as $i => $arg) { if (($type = gettype($arg)) !== $types[$i] and isset($types[$i]) and $types[$i] !== 'mixed') { throw new \InvalidArgumentException("Expected type of argument $i to be {$types[$i]}, got $type"); } } return call_user_func_array($fn, func_get_args()); }; return $wrapper; }; return $decorator; } function returns($type) { $decorator = function($fn) use ($type) { $wrapper = function() use ($fn, $type) { $returnValue = call_user_func_array($fn, func_get_args()); if (($returnType = gettype($returnValue)) !== $type) { throw new \UnexpectedValueException("Expected return type $type, got $returnType"); } return $returnValue; }; return $wrapper; }; return $decorator; } function bar() { return decorate( [ expects('integer'), returns('string') ], function($foo) { return "foo"; }, func_get_args() ); } bar(0); bar("foo");

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.0040.01416.75
8.3.50.0100.00817.45
8.3.40.0180.00318.92
8.3.30.0090.00618.62
8.3.20.0060.00318.85
8.3.10.0050.00320.53
8.3.00.0060.00319.50
8.2.180.0140.00716.63
8.2.170.0110.00722.96
8.2.160.0120.00321.20
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0000.00819.48
8.2.110.0090.00022.28
8.2.100.0000.01218.03
8.2.90.0060.00317.63
8.2.80.0040.00418.91
8.2.70.0030.00619.35
8.2.60.0090.00017.75
8.2.50.0040.00417.75
8.2.40.0040.00417.75
8.2.30.0000.00819.89
8.2.20.0060.00317.73
8.2.10.0040.00417.89
8.2.00.0040.00417.79
8.1.280.0110.00325.92
8.1.270.0040.00422.20
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00621.06
8.1.230.0110.00017.89
8.1.220.0080.00017.89
8.1.210.0050.00318.77
8.1.200.0000.00817.48
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0040.00417.62
8.1.160.0040.00419.01
8.1.150.0000.00818.75
8.1.140.0030.00517.52
8.1.130.0080.00017.89
8.1.120.0020.00517.52
8.1.110.0030.00417.55
8.1.100.0000.00717.48
8.1.90.0040.00417.48
8.1.80.0070.00017.54
8.1.70.0030.00317.41
8.1.60.0000.00817.66
8.1.50.0030.00617.52
8.1.40.0090.00017.63
8.1.30.0040.00417.71
8.1.20.0030.00517.66
8.1.10.0000.00817.60
8.1.00.0030.00617.58
8.0.300.0060.00318.99
8.0.290.0040.00416.88
8.0.280.0040.00418.57
8.0.270.0000.00716.96
8.0.260.0030.00316.93
8.0.250.0000.00917.10
8.0.240.0080.00017.14
8.0.230.0040.00417.05
8.0.220.0000.00716.91
8.0.210.0030.00416.98
8.0.200.0030.00316.95
8.0.190.0090.00017.05
8.0.180.0030.00617.05
8.0.170.0090.00017.04
8.0.160.0030.00316.92
8.0.150.0030.00617.00
8.0.140.0070.00316.89
8.0.130.0000.00713.54
8.0.120.0000.00716.95
8.0.110.0000.00816.92
8.0.100.0040.00417.07
8.0.90.0000.00716.99
8.0.80.0070.01016.94
8.0.70.0040.00417.08
8.0.60.0050.00316.84
8.0.50.0040.00417.04
8.0.30.0120.00717.06
8.0.20.0110.00817.11
8.0.10.0040.00417.20
8.0.00.0130.00616.95
7.4.330.0050.00013.07
7.4.320.0000.00816.57
7.4.300.0000.00716.70
7.4.290.0070.00016.58
7.4.280.0040.00416.68
7.4.270.0040.00416.66
7.4.260.0030.00313.45
7.4.250.0000.00916.48
7.4.240.0040.00416.69
7.4.230.0000.00716.75
7.4.220.0030.01916.71
7.4.210.0060.00816.69
7.4.200.0040.00416.70
7.4.190.0000.00716.48
7.4.160.0080.00816.52
7.4.150.0070.01016.71
7.4.140.0130.00816.71
7.4.130.0060.01116.69
7.4.120.0100.01116.56
7.4.110.0060.01216.51
7.4.100.0100.00716.59
7.4.90.0170.00916.48
7.4.80.0110.00719.39
7.4.70.0100.00616.56
7.4.60.0080.01316.64
7.4.50.0030.00616.43
7.4.40.0060.00616.46
7.4.30.0110.00516.62
7.4.10.0060.01214.89
7.4.00.0060.00914.94
7.3.330.0030.00313.49
7.3.320.0030.00313.48
7.3.310.0030.00316.44
7.3.300.0000.00716.32
7.3.290.0060.01016.38
7.3.280.0100.00616.44
7.3.270.0110.00616.70
7.3.260.0070.01116.41
7.3.250.0050.01316.68
7.3.240.0110.00616.68
7.3.230.0030.01316.70
7.3.210.0100.01016.54
7.3.200.0070.01316.45
7.3.190.0130.01016.76
7.3.180.0160.00016.54
7.3.170.0100.00616.51
7.3.160.0040.01216.45
7.3.130.0100.00614.84
7.3.120.0050.01014.88
7.3.110.0070.01314.85
7.3.100.0030.01114.93
7.3.90.0100.00315.12
7.3.80.0040.00414.93
7.3.70.0090.00614.86
7.3.60.0100.00314.84
7.3.50.0080.00814.91
7.3.40.0060.00315.04
7.3.30.0070.00715.02
7.3.20.0000.01616.46
7.3.10.0030.01216.74
7.3.00.0050.00616.74
7.2.330.0070.01116.87
7.2.320.0070.01616.82
7.2.310.0160.01616.48
7.2.300.0080.00816.38
7.2.290.0150.00616.84
7.2.260.0060.01314.96
7.2.250.0000.01815.29
7.2.240.0040.01115.11
7.2.230.0030.01014.90
7.2.220.0060.01215.09
7.2.210.0000.01514.98
7.2.200.0030.01515.04
7.2.190.0040.01115.21
7.2.180.0030.01215.11
7.2.170.0030.01115.13
7.2.160.0030.01215.21
7.2.150.0060.00917.04
7.2.140.0100.00317.11
7.2.130.0090.00616.96
7.2.120.0020.01216.96
7.2.110.0080.00516.90
7.2.100.0050.00616.81
7.2.90.0060.00816.93
7.2.80.0060.00816.88
7.2.70.0060.00616.78
7.2.60.0040.00816.82
7.2.50.0030.00916.79
7.2.40.0050.00916.92
7.2.30.0030.01116.99
7.2.20.0130.00216.99
7.2.10.0100.00416.88
7.2.00.0060.01017.80
7.1.330.0070.01015.54
7.1.320.0060.01215.54
7.1.310.0000.01415.94
7.1.300.0040.01215.78
7.1.290.0060.00615.66
7.1.280.0100.00715.86
7.1.270.0060.00315.82
7.1.260.0060.00915.84
7.1.250.0040.00915.66
7.1.240.0040.01115.59
7.1.230.0030.01015.95
7.1.220.0000.01015.76
7.1.210.0140.00315.90
7.1.200.0050.01015.74
7.1.190.0090.00615.96
7.1.180.0070.00715.51
7.1.170.0110.00315.64
7.1.160.0060.00616.01
7.1.150.0110.00415.77
7.1.140.0030.00715.79
7.1.130.0050.00515.98
7.1.120.0030.01416.01
7.1.110.0070.00715.75
7.1.100.0030.00917.08
7.1.90.0040.01115.79
7.1.80.0070.00715.76
7.1.70.0030.00916.35
7.1.60.0090.01217.50
7.1.50.0080.01016.33
7.1.40.0080.00815.93
7.1.30.0070.00315.63
7.1.20.0030.00615.88
7.1.10.0060.00315.61
7.1.00.0030.04419.11
7.0.330.0070.00715.62
7.0.320.0040.00715.50
7.0.310.0030.00915.43
7.0.300.0030.01215.59
7.0.290.0080.00515.55
7.0.280.0040.00715.50
7.0.270.0110.00315.44
7.0.260.0040.00715.14
7.0.250.0000.01715.44
7.0.240.0030.00815.25
7.0.230.0070.00715.11
7.0.220.0000.01115.50
7.0.210.0100.01015.39
7.0.200.0090.00515.11
7.0.190.0030.01215.34
7.0.180.0030.01015.60
7.0.170.0070.00715.51
7.0.160.0080.00615.43
7.0.150.0080.00415.35
7.0.140.0100.03718.72
7.0.130.0000.01215.38
7.0.120.0030.04218.78
7.0.110.0000.01415.54
7.0.100.0070.00715.36
7.0.90.0050.00515.59
7.0.80.0110.00315.27
7.0.70.0040.01115.30
7.0.60.0080.04217.61
7.0.50.0060.03116.63
7.0.40.0070.03916.83
7.0.30.0080.03216.82
7.0.20.0140.02416.87
7.0.10.0030.05316.80
7.0.00.0020.02916.90
5.6.400.0040.01114.63
5.6.390.0030.01314.31
5.6.380.0090.00614.61
5.6.370.0040.00814.70
5.6.360.0000.01014.49
5.6.350.0080.00814.48
5.6.340.0030.00914.35
5.6.330.0040.00814.17
5.6.320.0030.00614.46
5.6.310.0140.00714.59
5.6.300.0060.00914.28
5.6.290.0100.00314.50
5.6.280.0030.04217.70
5.6.270.0000.01614.58
5.6.260.0030.01014.24
5.6.250.0030.00714.55
5.6.240.0060.00614.60
5.6.230.0110.00414.52
5.6.220.0070.01014.19
5.6.210.0060.02517.66
5.6.200.0050.04716.35
5.6.190.0070.02517.45
5.6.180.0130.04017.52
5.6.170.0180.04217.60
5.6.160.0080.04317.40
5.6.150.0090.04416.43
5.6.140.0050.03016.24
5.6.130.0020.02816.33
5.6.120.0100.04517.76
5.6.110.0080.04317.72
5.6.100.0030.04317.70
5.6.90.0080.04517.65
5.6.80.0060.03917.51
5.6.70.0030.00714.34
5.6.60.0110.00314.34
5.6.50.0120.00414.29
5.6.40.0000.01414.21
5.6.30.0030.00914.27
5.6.20.0080.00414.30
5.6.10.0040.00714.09
5.6.00.0040.00714.38
5.5.380.0000.01314.26
5.5.370.0100.00714.21
5.5.360.0040.01114.31
5.5.350.0100.03817.51
5.5.340.0110.03816.14
5.5.330.0110.02317.24
5.5.320.0200.04117.55
5.5.310.0120.02417.34
5.5.300.0050.02316.06
5.5.290.0070.02515.99
5.5.280.0080.02717.69
5.5.270.0070.04517.45
5.5.260.0080.03317.46
5.5.250.0070.04717.55
5.5.240.0100.03017.09
5.5.230.0080.00814.11
5.5.220.0040.01114.32
5.5.210.0040.01114.36
5.5.200.0070.00714.54
5.5.190.0070.00714.49
5.5.180.0030.01014.04
5.5.170.0140.00014.39
5.5.160.0000.01414.09
5.5.150.0090.00614.37
5.5.140.0070.00714.23
5.5.130.0060.00314.22
5.5.120.0060.00914.27
5.5.110.0030.01414.23
5.5.100.0040.00714.12
5.5.90.0060.00914.35
5.5.80.0060.00914.22
5.5.70.0040.00413.88
5.5.60.0060.00914.19
5.5.50.0070.00714.34
5.5.40.0000.01514.26
5.5.30.0050.00313.97
5.5.20.0070.01014.06
5.5.10.0060.00814.06
5.5.00.0080.00814.27
5.4.450.0070.03215.79
5.4.440.0050.02315.95
5.4.430.0080.04315.90
5.4.420.0050.02315.87
5.4.410.0070.04115.84
5.4.400.0070.01815.60
5.4.390.0020.03315.63
5.4.380.0040.03715.79
5.4.370.0030.04015.79
5.4.360.0100.03715.59
5.4.350.0060.03515.73
5.4.340.0030.02515.74
5.4.330.0090.00012.33
5.4.320.0050.02415.74
5.4.310.0040.02315.59
5.4.300.0160.03215.79
5.4.290.0070.03215.74
5.4.280.0070.03215.79
5.4.270.0070.03915.79
5.4.260.0050.03415.79
5.4.250.0020.03015.72
5.4.240.0080.03615.66
5.4.230.0000.02915.74
5.4.220.0020.04615.74
5.4.210.0030.03415.62
5.4.200.0130.03315.76
5.4.190.0070.04015.74
5.4.180.0020.03715.72
5.4.170.0080.03815.78
5.4.160.0030.04015.59
5.4.150.0050.02315.64
5.4.140.0030.04314.40
5.4.130.0020.03814.39
5.4.120.0010.04114.40
5.4.110.0090.03514.38
5.4.100.0100.03714.38
5.4.90.0060.03614.38
5.4.80.0070.02014.43
5.4.70.0060.04014.39
5.4.60.0020.04614.38
5.4.50.0070.03814.30
5.4.40.0100.02014.40
5.4.30.0070.02914.36
5.4.20.0030.02814.35
5.4.10.0050.02714.41
5.4.00.0070.03214.11
5.3.290.0050.02113.53
5.3.280.0030.02813.50
5.3.270.0060.02313.50
5.3.260.0060.02813.54
5.3.250.0050.02513.57
5.3.240.0030.04013.49
5.3.230.0080.02913.51
5.3.220.0080.03113.47
5.3.210.0090.02313.47
5.3.200.0090.03913.46
5.3.190.0050.03713.47
5.3.180.0060.03913.49
5.3.170.0020.04613.47
5.3.160.0050.04313.50
5.3.150.0050.04013.46
5.3.140.0060.02613.46
5.3.130.0030.02813.42
5.3.120.0050.03913.42
5.3.110.0030.02913.46
5.3.100.0090.03213.24
5.3.90.0030.03913.15
5.3.80.0070.01813.18
5.3.70.0090.03413.15
5.3.60.0030.02713.18
5.3.50.0080.01813.16
5.3.40.0130.03713.16
5.3.30.0050.03313.17
5.3.20.0050.02513.11
5.3.10.0120.02613.04
5.3.00.0040.04412.99
5.2.170.0070.06011.15
5.2.160.0070.05311.11
5.2.150.0070.06311.22
5.2.140.0030.03011.14
5.2.130.0030.05711.18
5.2.120.0100.03011.27
5.2.110.0100.03011.07
5.2.100.0130.05711.15
5.2.90.0100.04711.14
5.2.80.0030.06711.09
5.2.70.0000.04711.11
5.2.60.0030.06711.20
5.2.50.0000.07010.91
5.2.40.0130.02710.93
5.2.30.0030.05010.92
5.2.20.0030.05010.88
5.2.10.0000.06710.91
5.2.00.0000.04710.66
5.1.60.0070.0509.98
5.1.50.0070.0379.96
5.1.40.0030.0509.95
5.1.30.0000.04010.41
5.1.20.0100.05710.39
5.1.10.0000.04310.06
5.1.00.0070.05310.05
5.0.50.0000.0478.52
5.0.40.0030.0478.47
5.0.30.0000.0608.22
5.0.20.0100.0338.17
5.0.10.0030.0238.12
5.0.00.0070.0408.20
4.4.90.0070.0307.88
4.4.80.0000.0207.88
4.4.70.0000.0237.88
4.4.60.0030.0237.88
4.4.50.0030.0337.88
4.4.40.0030.0537.88
4.4.30.0000.0377.88
4.4.20.0000.0307.88
4.4.10.0000.0407.88
4.4.00.0030.0577.88
4.3.110.0000.0377.88
4.3.100.0030.0137.88
4.3.90.0030.0337.88
4.3.80.0000.0537.88
4.3.70.0030.0337.88
4.3.60.0030.0337.88
4.3.50.0000.0377.88
4.3.40.0070.0377.88
4.3.30.0030.0307.88
4.3.20.0030.0207.88
4.3.10.0030.0307.88
4.3.00.0070.0207.88

preferences:
53.25 ms | 401 KiB | 5 Q