3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 1, 2, 3 ); $maxRetries = 5; class RetryIterator { protected static $_currentRetries = 0; public static function iterate($element) { var_dump($element); if ($element == 2) { throw new Exception('Something went wrong'); } } public static function handleException($e, $array) { var_dump('Exception handled'); } public static function retry(&$array, $maxRetries, $iterateCallback, $handleCallback) { while (!empty($array)) { reset($array); $key = key($array); try { call_user_func($iterateCallback, ($array[$key])); unset($array[$key]); } catch (Exception $e) { static::$_currentRetries++; if (static::$_currentRetries <= $maxRetries) { call_user_func($handleCallback, $e, $array); } else { throw new Exception('maxRetries reached'); } } } } } RetryIterator::retry($arr, 5, 'RetryIterator::iterate', 'RetryIterator::handleException');

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.40.0140.00719.00
8.3.30.0060.00919.21
8.3.20.0050.00220.39
8.3.10.0040.00422.00
8.3.00.0050.00322.43
8.2.170.0150.00022.96
8.2.160.0030.01020.93
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0030.01017.63
8.2.110.0070.00419.33
8.2.100.0000.01117.95
8.2.90.0000.00818.03
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0000.00818.05
8.2.50.0000.00918.07
8.2.40.0070.00018.34
8.2.30.0040.00418.20
8.2.20.0040.00417.72
8.2.10.0000.00717.75
8.2.00.0040.00417.77
8.1.270.0060.00322.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.59
8.1.230.0040.00720.89
8.1.220.0080.00017.78
8.1.210.0040.00418.95
8.1.200.0030.00617.35
8.1.190.0000.00817.35
8.1.180.0030.00618.10
8.1.170.0040.00418.53
8.1.160.0030.00518.90
8.1.150.0000.00718.66
8.1.140.0050.00217.46
8.1.130.0080.00017.85
8.1.120.0030.00317.53
8.1.110.0000.00817.38
8.1.100.0040.00417.45
8.1.90.0000.00717.48
8.1.80.0040.00417.48
8.1.70.0000.00817.43
8.1.60.0120.00017.52
8.1.50.0040.00417.44
8.1.40.0040.00417.60
8.1.30.0040.00417.54
8.1.20.0000.00817.60
8.1.10.0030.00617.52
8.1.00.0040.00417.53
8.0.300.0000.00719.98
8.0.290.0040.00416.75
8.0.280.0000.00718.50
8.0.270.0070.00017.34
8.0.260.0030.00316.91
8.0.250.0000.00716.93
8.0.240.0030.00316.97
8.0.230.0000.00717.04
8.0.220.0030.00317.02
8.0.210.0000.00716.82
8.0.200.0060.00017.02
8.0.190.0000.00816.91
8.0.180.0000.00717.00
8.0.170.0000.00816.99
8.0.160.0040.00416.92
8.0.150.0040.00716.82
8.0.140.0040.00416.95
8.0.130.0000.00613.36
8.0.120.0050.00316.92
8.0.110.0000.00816.93
8.0.100.0040.00416.87
8.0.90.0080.00016.77
8.0.80.0090.01317.04
8.0.70.0040.00417.03
8.0.60.0050.00216.93
8.0.50.0030.00516.93
8.0.30.0050.01717.13
8.0.20.0120.00617.42
8.0.10.0040.00417.04
8.0.00.0150.00316.70
7.4.330.0000.00515.00
7.4.320.0030.00316.45
7.4.300.0030.00316.62
7.4.290.0060.00316.47
7.4.280.0100.00016.56
7.4.270.0030.00516.39
7.4.260.0030.00316.58
7.4.250.0040.00416.63
7.4.240.0040.00416.54
7.4.230.0030.00316.65
7.4.220.0120.00616.47
7.4.210.0100.00916.66
7.4.200.0000.00716.60
7.4.190.0030.00316.71
7.4.160.0080.00816.55
7.4.150.0160.00917.40
7.4.140.0110.01017.86
7.4.130.0050.01216.64
7.4.120.0070.01016.66
7.4.110.0100.00716.66
7.4.100.0090.00916.61
7.4.90.0070.01116.48
7.4.80.0060.01519.39
7.4.70.0090.00916.68
7.4.60.0110.00716.53
7.4.50.0000.00916.66
7.4.40.0070.00422.77
7.4.30.0080.00816.70
7.4.00.0030.01514.86
7.3.330.0050.00013.38
7.3.320.0000.00613.36
7.3.310.0040.00416.24
7.3.300.0000.00816.38
7.3.290.0100.00316.39
7.3.280.0100.00816.40
7.3.270.0140.00417.40
7.3.260.0130.01316.47
7.3.250.0130.00416.53
7.3.240.0140.01016.67
7.3.230.0070.01116.55
7.3.210.0100.00616.38
7.3.200.0060.01216.51
7.3.190.0150.00316.52
7.3.180.0110.00516.51
7.3.170.0070.01016.52
7.3.160.0120.00916.49
7.3.120.0040.01114.97
7.2.330.0060.01216.63
7.2.320.0100.00716.65
7.2.310.0070.01516.45
7.2.300.0110.00616.83
7.2.290.0070.01016.63
7.2.60.0100.00716.87
7.2.00.0000.01119.44
7.1.200.0030.01015.89
7.1.100.0030.00918.11
7.1.70.0070.00417.30
7.1.60.0140.00419.82
7.1.50.0100.01317.05
7.1.00.0070.07322.41
7.0.200.0050.00216.52
7.0.140.0070.06721.95
7.0.60.0100.04319.93
7.0.50.0030.08017.90
7.0.40.0200.07720.30
7.0.30.0270.06020.31
7.0.20.0270.07020.22
7.0.10.0200.07720.21
7.0.00.0100.07720.30
5.6.280.0030.07321.11
5.6.210.0170.07320.73
5.6.200.0130.07318.23
5.6.190.0100.08020.55
5.6.180.0030.08320.50
5.6.170.0070.06320.48
5.6.160.0100.06720.49
5.6.150.0070.08018.23
5.6.140.0100.07718.21
5.6.130.0000.04318.17
5.6.120.0200.07021.02
5.6.110.0100.08021.01
5.6.100.0100.03320.99
5.6.90.0100.04720.97
5.6.80.0070.06720.38
5.5.350.0070.04320.30
5.5.340.0030.07318.04
5.5.330.0070.05020.23
5.5.320.0000.05020.42
5.5.310.0370.07720.24
5.5.300.0230.04018.08
5.5.290.0130.07718.09
5.5.280.0130.05320.68
5.5.270.0130.08020.87
5.5.260.0070.04320.73
5.5.250.0170.07320.72
5.5.240.0030.08020.28
5.4.450.0530.05319.58
5.4.440.0570.06019.60
5.4.430.0200.07019.43
5.4.420.0170.05019.42
5.4.410.0170.06019.00
5.4.400.0230.04018.59
5.4.390.0100.05018.79
5.4.380.0100.05318.73
5.4.370.0670.06018.70
5.4.360.0770.05718.51
5.4.350.1070.05718.63
5.4.340.0870.05318.73
5.4.320.0050.04112.51
5.4.310.0090.03512.51
5.4.300.0100.03912.51
5.4.290.0050.04512.51
5.4.280.0070.03312.41
5.4.270.0050.03712.41
5.4.260.0100.07319.10
5.4.250.0130.05318.96
5.4.240.0170.07718.95
5.4.230.0170.06719.00
5.4.220.0000.06318.96
5.4.210.0170.04318.99
5.4.200.0100.05018.95
5.4.190.0130.04718.96
5.4.180.0170.05318.98
5.4.170.0200.05719.02
5.4.160.0100.07718.95
5.4.150.0130.07318.78
5.4.140.0170.04316.41
5.4.130.0070.04716.40
5.4.120.0130.05316.39
5.4.110.0030.05716.42
5.4.100.0200.05316.42
5.4.90.0000.05716.62
5.4.80.0030.05316.55
5.4.70.0100.04716.33
5.4.60.0100.04716.46
5.4.50.0100.04716.51
5.4.40.0100.04716.36
5.4.30.0100.04716.61
5.4.20.0100.05016.47
5.4.10.0100.05016.35
5.4.00.0100.06715.86
5.3.290.0070.04312.80
5.3.280.0070.05314.79
5.3.270.0070.05014.60
5.3.260.0130.04714.62
5.3.250.0030.07314.70
5.3.240.0130.05014.75
5.3.230.0170.04314.70
5.3.220.0170.04314.80
5.3.210.0100.05014.60
5.3.200.0100.05014.59
5.3.190.0130.05014.81
5.3.180.0070.05014.56
5.3.170.0030.06014.80
5.3.160.0130.06314.67
5.3.150.0130.05014.66
5.3.140.0130.05314.63
5.3.130.0070.05314.79
5.3.120.0000.06014.55
5.3.110.0130.04714.55
5.3.100.0030.05313.91
5.3.90.0170.06314.11
5.3.80.0070.07014.11
5.3.70.0070.05714.10
5.3.60.0170.06014.10
5.3.50.0130.06714.04
5.3.40.0000.05314.05
5.3.30.0130.04013.92
5.3.20.0070.04713.79
5.3.10.0100.04313.63
5.3.00.0100.04713.64
5.2.170.0000.06710.98
5.2.160.0070.04011.05
5.2.150.0130.05311.23
5.2.140.0030.04011.13
5.2.130.0030.04011.09
5.2.120.0070.05710.93
5.2.110.0000.04311.27
5.2.100.0100.04010.94
5.2.90.0070.03711.06
5.2.80.0070.04311.26
5.2.70.0130.04311.17
5.2.60.0000.04311.15
5.2.50.0070.04311.21
5.2.40.0000.04311.09
5.2.30.0130.04711.07
5.2.20.0100.04311.14
5.2.10.0030.04010.94
5.2.00.0000.04310.82
5.1.60.0100.0409.98
5.1.50.0070.03310.09
5.1.40.0070.0309.96
5.1.30.0030.03710.18
5.1.20.0030.03710.58
5.1.10.0000.04010.24
5.1.00.0030.03710.14
5.0.50.0000.0308.55
5.0.40.0030.0308.51
5.0.30.0000.0638.43
5.0.20.0070.0278.12
5.0.10.0030.0278.18
5.0.00.0100.0538.22
4.4.90.0070.0176.84
4.4.80.0000.0276.84
4.4.70.0030.0206.84
4.4.60.0000.0236.84
4.4.50.0030.0206.84
4.4.40.0000.0376.84
4.4.30.0030.0276.84
4.4.20.0000.0306.84
4.4.10.0030.0206.84
4.4.00.0070.0306.84
4.3.110.0070.0236.84
4.3.100.0070.0176.84
4.3.90.0030.0306.84
4.3.80.0030.0336.84
4.3.70.0130.0206.84
4.3.60.0070.0176.84
4.3.50.0070.0176.84
4.3.40.0030.0306.84
4.3.30.0030.0206.84
4.3.20.0000.0236.84
4.3.10.0000.0236.84
4.3.00.0030.0206.86

preferences:
47.53 ms | 400 KiB | 5 Q