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 (array) "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.0070.01116.75
8.3.50.0190.01017.18
8.3.40.0160.00718.71
8.3.30.0000.01418.79
8.3.20.0040.00418.91
8.3.10.0000.00918.77
8.3.00.0000.00919.51
8.2.180.0070.00718.50
8.2.170.0030.01022.96
8.2.160.0030.01020.55
8.2.150.0060.00324.18
8.2.140.0050.00224.66
8.2.130.0040.00426.16
8.2.120.0080.00020.87
8.2.110.0070.00320.89
8.2.100.0070.00417.97
8.2.90.0050.00318.16
8.2.80.0050.00318.28
8.2.70.0080.00417.63
8.2.60.0050.00317.63
8.2.50.0040.00417.63
8.2.40.0000.00819.35
8.2.30.0000.00718.12
8.2.20.0030.00617.77
8.2.10.0050.00317.93
8.2.00.0050.00317.86
8.1.280.0100.01025.92
8.1.270.0070.01023.99
8.1.260.0000.00926.35
8.1.250.0080.00028.09
8.1.240.0000.00822.55
8.1.230.0090.00321.14
8.1.220.0000.00817.74
8.1.210.0090.00018.84
8.1.200.0050.00317.47
8.1.190.0030.00517.47
8.1.180.0080.00018.10
8.1.170.0080.00018.96
8.1.160.0000.00722.19
8.1.150.0030.00618.64
8.1.140.0060.00317.51
8.1.130.0080.00019.23
8.1.120.0000.00717.53
8.1.110.0070.00017.38
8.1.100.0040.00417.50
8.1.90.0040.00417.40
8.1.80.0040.00317.43
8.1.70.0030.00517.44
8.1.60.0040.00417.52
8.1.50.0030.00517.50
8.1.40.0030.00617.61
8.1.30.0000.00917.72
8.1.20.0000.00917.72
8.1.10.0000.00817.64
8.1.00.0050.00317.54
8.0.300.0000.00720.16
8.0.290.0030.00516.88
8.0.280.0030.00318.47
8.0.270.0080.00018.17
8.0.260.0000.00716.86
8.0.250.0040.00417.09
8.0.240.0030.00517.11
8.0.230.0040.00417.14
8.0.220.0030.00517.03
8.0.210.0040.00416.93
8.0.200.0040.00416.96
8.0.190.0030.00516.97
8.0.180.0050.00217.02
8.0.170.0030.00517.01
8.0.160.0040.00416.99
8.0.150.0080.00016.94
8.0.140.0040.00416.95
8.0.130.0050.00013.41
8.0.120.0060.00316.95
8.0.110.0040.00416.92
8.0.100.0050.00316.89
8.0.90.0080.00016.82
8.0.80.0050.00916.95
8.0.70.0000.00717.08
8.0.60.0020.00617.05
8.0.50.0030.00517.05
8.0.30.0100.01317.14
8.0.20.0120.00917.28
8.0.10.0000.00717.15
8.0.00.0110.00916.90
7.4.330.0020.00213.03
7.4.320.0030.00316.67
7.4.300.0040.00416.59
7.4.290.0040.00416.54
7.4.280.0000.00816.71
7.4.270.0040.00416.57
7.4.260.0050.00013.34
7.4.250.0040.00416.68
7.4.240.0000.00716.65
7.4.230.0040.00416.70
7.4.220.0140.00416.63
7.4.210.0050.01116.64
7.4.200.0030.00316.67
7.4.190.0030.00616.47
7.4.160.0080.00816.81
7.4.150.0180.00016.64
7.4.140.0130.00617.86
7.4.130.0120.00816.54
7.4.120.0060.01516.76
7.4.110.0100.01316.67
7.4.100.0100.00716.63
7.4.90.0140.00316.61
7.4.80.0100.01919.39
7.4.70.0140.00716.46
7.4.60.0030.01316.50
7.4.50.0000.00716.70
7.4.40.0030.01016.64
7.4.30.0130.00416.70
7.4.00.0050.01015.00
7.3.330.0030.00313.30
7.3.320.0000.00513.30
7.3.310.0000.00816.45
7.3.300.0030.00316.45
7.3.290.0100.00716.41
7.3.280.0090.01016.42
7.3.270.0130.00716.73
7.3.260.0170.00016.54
7.3.240.0040.01216.66
7.3.230.0100.01016.57
7.3.210.0090.01316.54
7.3.200.0070.01416.51
7.3.190.0060.01016.53
7.3.180.0120.00316.46
7.3.170.0060.01016.46
7.3.160.0070.00816.49
7.3.120.0070.00914.96
7.3.110.0090.00714.77
7.3.100.0060.00614.99
7.3.90.0030.01114.71
7.3.80.0030.01214.66
7.3.70.0050.00714.87
7.3.60.0080.00614.86
7.3.50.0090.00614.72
7.3.40.0050.00614.88
7.3.30.0050.00514.95
7.3.20.0050.01016.75
7.3.10.0120.00516.64
7.3.00.0050.00716.67
7.2.330.0110.00616.73
7.2.320.0070.01116.57
7.2.310.0100.01016.61
7.2.300.0090.00616.88
7.2.290.0120.00616.61
7.2.250.0050.01314.86
7.2.240.0120.00615.24
7.2.230.0070.01014.93
7.2.220.0060.01215.25
7.2.210.0100.00715.16
7.2.200.0030.01015.14
7.2.190.0040.01214.98
7.2.180.0030.01214.98
7.2.170.0060.00915.16
7.2.60.0910.01014.83
7.2.00.0040.01219.46
7.1.330.0050.00815.84
7.1.320.0050.01015.81
7.1.310.0070.00815.84
7.1.300.0050.00815.76
7.1.290.0080.00815.89
7.1.280.0090.00315.74
7.1.270.0030.01215.76
7.1.260.0110.00315.84
7.1.200.0100.00315.91
7.1.100.0050.00518.01
7.1.70.0030.00517.25
7.1.60.0190.00719.25
7.1.50.0230.01034.93
7.1.00.0000.08022.45
7.0.200.0000.01416.82
7.0.140.0100.06722.00
7.0.120.0070.07022.09
7.0.60.0030.06719.83
7.0.50.0070.04717.96
7.0.40.0230.05320.32
7.0.30.0430.04720.10
7.0.20.0200.05320.23
7.0.10.0330.07320.20
7.0.00.0030.05020.07
5.6.280.0100.09020.85
5.6.210.0070.08020.69
5.6.200.0070.05318.20
5.6.190.0070.04020.61
5.6.180.0230.07320.42
5.6.170.0230.07720.51
5.6.160.0070.03720.43
5.6.150.0030.04318.16
5.6.140.0170.06718.18
5.6.130.0030.05018.21
5.6.120.0170.07321.05
5.6.110.0100.05321.03
5.6.100.0170.04721.02
5.6.90.0100.08720.98
5.6.80.0130.07720.41
5.6.70.4600.04020.42
5.5.350.0100.08720.43
5.5.340.0130.03018.02
5.5.330.0100.06720.43
5.5.320.0400.04020.51
5.5.310.0300.07320.37
5.5.300.0170.07317.97
5.5.290.0030.04318.00
5.5.280.0070.04720.71
5.5.270.0000.08720.68
5.5.260.0030.05020.89
5.5.250.0030.06320.72
5.5.240.4300.02720.19
5.4.450.0900.04019.53
5.4.440.0570.04319.39
5.4.430.0800.03719.48
5.4.420.0300.04719.54
5.4.410.0670.04319.27
5.4.400.0530.02719.20
5.4.390.0700.03018.97
5.4.380.0470.03319.02
5.4.370.0630.03719.17
5.4.360.0770.05319.23
5.4.350.0800.04019.02
5.4.340.0500.05319.14
5.4.320.0500.04319.16
5.4.310.0330.03719.23
5.4.300.0770.05019.13
5.4.290.0630.04319.02
5.4.280.0570.04319.02
5.4.270.0970.01719.22
5.4.260.0670.03019.02
5.4.250.0570.03719.13
5.4.240.0270.04319.16
5.4.230.0370.04019.22
5.4.220.0500.04719.13
5.4.210.0270.04719.02
5.4.200.0700.04319.30
5.4.190.1030.02719.02
5.4.180.0500.02719.21
5.4.170.0570.03319.02
5.4.160.0630.03719.12
5.4.150.0670.02719.14
5.4.140.0530.03719.02
5.4.130.0630.03718.98
5.4.120.0500.03318.98
5.4.110.0630.03718.98
5.4.100.0730.03018.98
5.4.90.0470.03718.98
5.4.80.0470.05018.98
5.4.70.0230.04018.98
5.4.60.0670.03018.98
5.4.50.0270.04018.98
5.4.40.0630.04018.98
5.4.30.0700.03318.98
5.4.20.0370.04318.98
5.4.10.0730.03718.98
5.4.00.0530.04318.98
5.3.290.0730.04719.02
5.3.280.0300.04719.02
5.3.270.0330.06019.02
5.3.260.0200.04719.02
5.3.250.0430.04019.02
5.3.240.0800.03019.02
5.3.230.0370.03018.98
5.3.220.0830.03318.98
5.3.210.0230.04718.98
5.3.200.0330.04018.98
5.3.190.0700.03718.98
5.3.180.0630.04018.98
5.3.170.0530.04318.98
5.3.160.0800.03718.98
5.3.150.0500.04318.98
5.3.140.0530.03718.98
5.3.130.0500.04018.98
5.3.120.0730.02018.98
5.3.110.0530.04018.98
5.3.100.0570.04318.98
5.3.90.0600.04018.98
5.3.80.0370.04018.98
5.3.70.0570.03318.98
5.3.60.0630.03018.98
5.3.50.0770.03718.98
5.3.40.0470.04018.98
5.3.30.0870.02718.98
5.3.20.0500.04318.98
5.3.10.0530.04018.98
5.3.00.0670.04018.98
5.2.170.0700.02318.98
5.2.160.0470.02718.98
5.2.150.0630.02718.98
5.2.140.0300.04018.98
5.2.130.0330.02718.98
5.2.120.0470.03318.98
5.2.110.0370.02018.98
5.2.100.0730.02318.98
5.2.90.0670.02718.98
5.2.80.0470.03318.98
5.2.70.0330.03018.98
5.2.60.0400.02318.98
5.2.50.0470.03318.98
5.2.40.0530.01718.98
5.2.30.0470.03018.98
5.2.20.0500.03718.98
5.2.10.0230.03018.98
5.2.00.0370.02718.98
5.1.60.0330.02018.98
5.1.50.0170.02718.98
5.1.40.0230.02718.98
5.1.30.0330.02018.98
5.1.20.0630.01718.98
5.1.10.0500.02718.98
5.1.00.0330.02718.98
5.0.50.0230.01718.98
5.0.40.0100.02318.98
5.0.30.0230.02718.98
5.0.20.0200.01718.98
5.0.10.0100.01718.98
5.0.00.0100.03318.98
4.4.90.0230.01318.98
4.4.80.0030.02318.98
4.4.70.0100.01718.98
4.4.60.0300.01018.98
4.4.50.0200.01718.98
4.4.40.0200.03018.98
4.4.30.0230.01718.98
4.4.20.0100.01318.98
4.4.10.0270.01318.98
4.4.00.0030.02718.98
4.3.110.0100.01318.98
4.3.100.0300.01018.98
4.3.90.0130.02018.98
4.3.80.0130.04318.98
4.3.70.0000.01318.98
4.3.60.0100.01718.98
4.3.50.0130.01718.98
4.3.40.0070.01318.98
4.3.30.0100.01718.98
4.3.20.0000.03018.98
4.3.10.0130.01318.98
4.3.00.0130.02018.98

preferences:
62.99 ms | 401 KiB | 5 Q