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 decorator(callable $decorator) { // This function replaces 'trace' return function($wrapped) use ($decorator) { // This function replaces the function which 'trace' is used on. return function() use ($wrapped, $decorator) { var_dump($wrapped); $arguments = func_get_args(); return call_user_func($decorator, $wrapped, $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 trace(callable $fn) { return decorate( ['decorator'], function($fn, $arguments) { printf("Calling %s with arguments %s\n", print_r($fn, true), print_r($arguments, true)); return call_user_func_array($fn, $arguments); }, func_get_args() ); } function foo() { return decorate(['trace'], function() { echo "Hello World\n"; }, func_get_args()); } function bar() { return decorate( [returns('string')], function() { return "foo"; }, func_get_args() ); } 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.0090.00616.37
8.3.50.0160.00517.44
8.3.40.0110.00318.82
8.3.30.0100.00618.59
8.3.20.0000.00818.89
8.3.10.0030.00618.69
8.3.00.0030.00619.38
8.2.180.0090.00616.50
8.2.170.0090.00622.96
8.2.160.0120.00621.16
8.2.150.0050.00324.18
8.2.140.0000.00924.66
8.2.130.0050.00326.16
8.2.120.0070.00022.26
8.2.110.0060.00321.09
8.2.100.0110.00017.91
8.2.90.0060.00319.48
8.2.80.0000.00719.38
8.2.70.0060.00317.50
8.2.60.0070.00318.02
8.2.50.0050.00518.07
8.2.40.0090.00018.28
8.2.30.0070.00018.06
8.2.20.0040.00417.73
8.2.10.0050.00317.77
8.2.00.0000.00917.59
8.1.280.0150.00425.92
8.1.270.0000.00824.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00922.48
8.1.230.0040.00720.91
8.1.220.0060.00317.79
8.1.210.0030.00518.91
8.1.200.0060.00317.36
8.1.190.0040.00417.40
8.1.180.0030.00618.10
8.1.170.0080.00018.76
8.1.160.0070.00018.79
8.1.150.0040.00418.63
8.1.140.0000.01017.40
8.1.130.0030.00317.85
8.1.120.0070.00017.52
8.1.110.0000.00717.55
8.1.100.0000.00717.47
8.1.90.0040.00417.39
8.1.80.0040.00417.44
8.1.70.0040.00417.42
8.1.60.0030.00517.55
8.1.50.0060.00317.51
8.1.40.0060.00317.58
8.1.30.0000.00817.61
8.1.20.0000.00817.70
8.1.10.0000.00817.49
8.1.00.0050.00317.60
8.0.300.0050.00220.03
8.0.290.0000.00816.75
8.0.280.0080.00018.47
8.0.270.0030.00317.34
8.0.260.0070.00016.91
8.0.250.0080.00017.06
8.0.240.0000.00817.02
8.0.230.0050.00317.03
8.0.220.0080.00016.96
8.0.210.0040.00716.90
8.0.200.0040.00417.07
8.0.190.0040.00417.04
8.0.180.0070.00017.07
8.0.170.0030.00616.93
8.0.160.0050.00317.00
8.0.150.0060.00316.84
8.0.140.0080.00316.85
8.0.130.0060.00013.49
8.0.120.0040.00416.85
8.0.110.0000.00716.87
8.0.100.0040.00417.04
8.0.90.0000.00716.86
8.0.80.0100.01016.91
8.0.70.0060.00317.06
8.0.60.0080.00016.91
8.0.50.0000.00816.77
8.0.30.0100.01017.17
8.0.20.0110.01417.00
8.0.10.0000.00817.15
8.0.00.0090.00916.88
7.4.330.0000.00613.10
7.4.320.0030.00316.54
7.4.300.0000.00716.59
7.4.290.0070.00316.57
7.4.280.0000.00816.60
7.4.270.0000.00716.63
7.4.260.0030.00313.27
7.4.250.0060.00316.51
7.4.240.0030.00316.54
7.4.230.0030.00316.76
7.4.220.0060.01216.72
7.4.210.0070.00816.60
7.4.200.0070.00016.56
7.4.190.0070.00016.46
7.4.160.0120.00316.52
7.4.150.0060.01116.45
7.4.140.0060.01416.57
7.4.130.0110.00716.59
7.4.120.0080.00916.56
7.4.110.0110.00516.42
7.4.100.0140.00716.63
7.4.90.0160.00616.59
7.4.80.0070.01119.39
7.4.70.0080.00716.67
7.4.60.0040.01216.51
7.4.50.0050.00516.68
7.4.40.0060.00616.70
7.4.30.0060.01016.39
7.4.00.0100.00314.94
7.3.330.0020.00513.38
7.3.320.0030.00313.41
7.3.310.0030.00516.32
7.3.300.0070.00016.28
7.3.290.0130.00316.33
7.3.280.0100.00716.41
7.3.270.0120.00416.43
7.3.260.0120.00616.68
7.3.250.0100.01216.43
7.3.240.0090.00916.55
7.3.230.0120.01216.55
7.3.210.0070.01016.38
7.3.200.0150.00716.57
7.3.190.0190.00316.43
7.3.180.0060.00916.50
7.3.170.0160.00316.52
7.3.160.0140.00716.32
7.3.120.0060.00615.05
7.2.330.0220.01716.87
7.2.320.0140.00716.88
7.2.310.0110.01116.69
7.2.300.0080.00816.71
7.2.290.0070.01016.72
7.2.120.0060.01016.46
7.2.110.0030.00916.39
7.2.100.0070.00716.78
7.2.90.0090.00616.77
7.2.80.0070.00716.52
7.2.70.0030.00616.95
7.2.60.0080.00816.87
7.2.50.0030.01116.71
7.2.40.0100.00716.77
7.2.30.0070.01017.09
7.2.20.0110.00016.98
7.2.10.0030.01016.94
7.2.00.0060.00518.18
7.1.240.0030.00615.59
7.1.230.0000.00915.71
7.1.220.0060.00615.67
7.1.210.0030.00615.50
7.1.200.0030.01015.77
7.1.190.0070.00715.87
7.1.180.0050.00515.63
7.1.170.0040.01115.81
7.1.160.0070.00415.79
7.1.150.0060.00315.88
7.1.140.0060.00815.79
7.1.130.0040.00415.77
7.1.120.0000.01415.87
7.1.110.0030.01115.70
7.1.100.0060.00417.02
7.1.90.0060.00915.74
7.1.80.0000.01715.95
7.1.70.0050.01016.49
7.1.60.0120.00617.51
7.1.50.0090.00925.24
7.1.40.0060.00615.81
7.1.30.0090.00315.60
7.1.20.0000.01615.91
7.1.10.0100.00315.71
7.1.00.0030.03319.07
7.0.320.0030.01215.43
7.0.310.0070.00715.39
7.0.300.0070.00715.33
7.0.290.0080.00415.05
7.0.280.0000.01215.29
7.0.270.0070.00715.41
7.0.260.0040.00415.15
7.0.250.0030.00515.58
7.0.240.0030.01015.44
7.0.230.0070.00015.48
7.0.220.0060.00815.18
7.0.210.0030.00915.32
7.0.200.0180.00315.09
7.0.190.0070.00415.45
7.0.180.0050.00215.29
7.0.170.0060.00315.45
7.0.160.0090.00315.47
7.0.150.0040.01115.55
7.0.140.0060.04118.71
7.0.130.0080.00315.48
7.0.120.0020.04018.64
7.0.110.0030.00915.11
7.0.100.0110.00415.42
7.0.90.0100.00315.24
7.0.80.0070.00715.44
7.0.70.0100.00315.62
7.0.60.0080.03817.73
7.0.50.0090.04016.67
7.0.40.0030.03016.92
7.0.30.0190.02016.82
7.0.20.0130.03016.89
7.0.10.0170.03216.90
7.0.00.0000.04916.77
5.6.380.0030.01314.46
5.6.370.0000.01414.41
5.6.360.0060.00314.42
5.6.350.0060.00614.77
5.6.340.0000.01414.18
5.6.330.0100.00314.43
5.6.320.0110.00314.31
5.6.310.0090.00314.36
5.6.300.0030.00714.46
5.6.290.0110.00314.63
5.6.280.0020.04317.72
5.6.270.0100.00714.40
5.6.260.0100.00714.47
5.6.250.0070.00714.21
5.6.240.0090.00614.14
5.6.230.0030.00714.60
5.6.220.0120.00314.11
5.6.210.0100.04217.47
5.6.200.0020.03216.20
5.6.190.0110.02017.42
5.6.180.0200.04017.43
5.6.170.0230.04517.31
5.6.160.0030.04917.51
5.6.150.0050.04216.31
5.6.140.0070.04216.44
5.6.130.0100.03816.29
5.6.120.0130.04117.69
5.6.110.0030.05117.63
5.6.100.0040.04617.96
5.6.90.0080.02117.59
5.6.80.0100.02517.29
5.6.70.0150.04117.47
5.6.60.0060.01014.37
5.6.50.0110.00014.17
5.6.40.0070.00714.25
5.6.30.0040.00714.14
5.6.20.0120.00314.44
5.6.10.0080.00414.02
5.6.00.0000.01214.34
5.5.380.0030.00611.43
5.5.370.0070.00411.27
5.5.360.0030.00311.27
5.5.350.0160.03015.96
5.5.340.0030.03314.66
5.5.330.0060.03115.78
5.5.320.0070.02615.77
5.5.310.0180.02815.79
5.5.300.0010.03314.63
5.5.290.0030.03814.68
5.5.280.0080.02816.09
5.5.270.0060.02116.00
5.5.260.0060.02816.06
5.5.250.0070.04116.00
5.5.240.0030.02015.81
5.5.230.0040.00711.27
5.5.220.0040.00711.27
5.5.210.0000.00711.27
5.5.200.0000.00611.27
5.5.190.0030.00311.27
5.5.180.0040.00711.39
5.5.170.0100.00314.07
5.5.160.0030.00511.27
5.5.150.0000.00911.33
5.5.140.0030.00311.27
5.5.130.0060.00811.27
5.5.120.0030.00711.27
5.5.110.0000.01011.29
5.5.100.0040.00711.27
5.5.90.0040.00811.27
5.5.80.0000.01211.27
5.5.70.0040.00811.34
5.5.60.0030.01011.27
5.5.50.0040.00811.29
5.5.40.0040.00811.27
5.5.30.0060.00611.27
5.5.20.0030.01011.33
5.5.10.0030.00311.27
5.5.00.0110.00011.30
5.4.450.0070.04215.27
5.4.440.0030.03315.43
5.4.430.0080.04115.37
5.4.420.0030.03115.40
5.4.410.0070.03915.23
5.4.400.0050.02715.21
5.4.390.0100.03415.06
5.4.380.0020.04115.21
5.4.370.0040.02315.24
5.4.360.0020.04315.21
5.4.350.0080.03415.18
5.4.340.0030.03815.10
5.4.330.0100.00311.39
5.4.320.0030.04015.22
5.4.310.0040.02615.14
5.4.300.0060.04115.26
5.4.290.0050.03215.07
5.4.280.0070.04015.26
5.4.270.0060.02915.25
5.4.260.0070.04015.19
5.4.250.0040.02615.21
5.4.240.0020.04415.07
5.4.230.0070.03715.06
5.4.220.0050.03315.26
5.4.210.0020.03715.25
5.4.200.0070.03815.21
5.4.190.0030.04615.09
5.4.180.0050.04315.30
5.4.170.0090.03715.25
5.4.160.0050.02215.20
5.4.150.0070.03715.25
5.4.140.0060.02613.87
5.4.130.0020.02113.88
5.4.120.0060.02513.93
5.4.110.0050.02213.89
5.4.100.0030.02913.88
5.4.90.0090.03713.80
5.4.80.0060.02513.89
5.4.70.0050.04013.92
5.4.60.0050.02713.90
5.4.50.0020.02513.99
5.4.40.0080.02313.80
5.4.30.0030.04113.84
5.4.20.0050.03713.83
5.4.10.0000.04213.80
5.4.00.0090.02413.55
5.3.290.0090.02813.08
5.3.280.0100.03212.97
5.3.270.0120.03312.97
5.3.260.0030.02212.96
5.3.250.0030.02212.94
5.3.240.0060.03012.98
5.3.230.0020.02713.04
5.3.220.0070.02513.03
5.3.210.0080.03512.98
5.3.200.0070.02012.94
5.3.190.0050.04012.97
5.3.180.0040.04212.89
5.3.170.0030.03312.96
5.3.160.0030.02812.98
5.3.150.0050.02812.97
5.3.140.0060.03212.90
5.3.130.0030.04012.96
5.3.120.0070.04112.94
5.3.110.0040.04412.96
5.3.100.0040.04012.68
5.3.90.0060.03812.68
5.3.80.0090.03712.70
5.3.70.0050.02212.68
5.3.60.0060.02612.62
5.3.50.0030.02312.64
5.3.40.0110.03512.66
5.3.30.0090.03012.62
5.3.20.0030.02412.51
5.3.10.0070.03212.50
5.3.00.0030.03512.56
5.2.170.0070.03211.19
5.2.160.0100.02711.23
5.2.150.0020.03911.24
5.2.140.0080.03111.21
5.2.130.0020.03011.22
5.2.120.0030.02111.19
5.2.110.0060.03211.17
5.2.100.0000.02011.21
5.2.90.0070.03011.21
5.2.80.0060.01511.22
5.2.70.0030.03211.20
5.2.60.0080.02311.19
5.2.50.0030.02711.18
5.2.40.0050.03311.16
5.2.30.0000.03711.14
5.2.20.0020.03211.15
5.2.10.0000.02411.14
5.2.00.0030.02110.96
5.1.60.0020.01710.66
5.1.50.0050.02610.59
5.1.40.0040.02910.63
5.1.30.0000.02510.84
5.1.20.0040.02810.81
5.1.10.0030.03110.75
5.1.00.0020.02510.63
5.0.50.0000.0299.90
5.0.40.0020.0259.85
5.0.30.0030.0259.73
5.0.20.0040.0129.77
5.0.10.0040.0219.71
5.0.00.0030.0339.73
4.4.90.0010.0219.45
4.4.80.0020.0199.45
4.4.70.0030.0159.45
4.4.60.0000.0169.45
4.4.50.0040.0159.45
4.4.40.0020.0139.45
4.4.30.0020.0209.45
4.4.20.0000.0189.45
4.4.10.0010.0119.45
4.4.00.0000.0309.45
4.3.110.0020.0179.45
4.3.100.0000.0159.45
4.3.90.0000.0109.45
4.3.80.0030.0239.45
4.3.70.0050.0169.45
4.3.60.0000.0179.45
4.3.50.0040.0079.45
4.3.40.0030.0259.45
4.3.30.0010.0139.45
4.3.20.0030.0159.45
4.3.10.0040.0089.45
4.3.00.0010.0219.45

preferences:
52.64 ms | 400 KiB | 5 Q