3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iterator = new class implements \Iterator { private $values = [1, 2, 3]; private $key; public function current() { return current($this->values); } public function next() { next($this->values); } public function key() { return $this->key; } public function valid() { return current($this->values) !== false; } public function rewind() { echo "Rewinding\n"; reset($this->values); } }; $generator = (function () { yield 1; yield 2; yield 3; })(); $wrappedIterator = (function($iterator) { foreach ($iterator as $value) { yield $value; } })($iterator); function skipOne(\Iterator $iterator) { $iterator->next(); echo "Skipped one\n"; yield from $iterator; } echo "\nUsing skipOne(iterator):\n"; foreach (skipOne($iterator) as $value) { var_dump($value); } echo "\nUsing skipOne(generator):\n"; foreach (skipOne($generator) as $value) { var_dump($value); } echo "\nUsing skipOne(wrappedIterator):\n"; foreach(skipOne($wrappedIterator) as $value) { var_dump($value); } echo "\nUsing foreach(iterator):\n"; foreach($iterator as $value) { var_dump($value); }

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.4.120.0140.00524.21
8.4.110.0130.00922.37
8.4.100.0140.00617.84
8.4.90.0120.00918.70
8.4.80.0060.00518.05
8.4.70.0030.00517.78
8.4.60.0070.01418.96
8.4.50.0100.00917.96
8.4.40.0130.00719.55
8.4.30.0060.01218.70
8.4.20.0120.00620.59
8.4.10.0060.00317.95
8.3.250.0130.00618.88
8.3.240.0100.01016.93
8.3.230.0170.00316.57
8.3.220.0120.00716.97
8.3.210.0120.00716.86
8.3.200.0140.00616.48
8.3.190.0070.00217.11
8.3.180.0090.00720.64
8.3.170.0070.01016.61
8.3.160.0150.00316.87
8.3.150.0060.00916.95
8.3.140.0000.00818.84
8.3.130.0000.00818.59
8.3.120.0080.01120.67
8.3.110.0040.00420.94
8.3.100.0070.01424.06
8.3.90.0160.00626.77
8.3.80.0030.00619.36
8.3.70.0040.01116.63
8.3.60.0110.00718.68
8.3.50.0090.01018.15
8.3.40.0100.00718.59
8.3.30.0110.00418.67
8.3.20.0070.00720.60
8.3.10.0080.00023.66
8.3.00.0040.00423.48
8.2.290.0090.01120.37
8.2.280.0090.00918.48
8.2.270.0090.00916.93
8.2.260.0040.00418.79
8.2.250.0040.00416.96
8.2.240.0090.00617.17
8.2.230.0030.00622.58
8.2.220.0090.00637.54
8.2.210.0110.00426.77
8.2.200.0100.00018.88
8.2.190.0070.01320.25
8.2.180.0150.00616.63
8.2.170.0150.00622.96
8.2.160.0110.00422.25
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0040.00420.89
8.2.110.0000.01020.52
8.2.100.0150.00017.73
8.2.90.0050.00319.09
8.2.80.0000.00817.97
8.2.70.0030.00517.63
8.2.60.0000.00917.63
8.2.50.0050.00317.63
8.2.40.0050.00319.48
8.2.30.0040.00419.46
8.2.20.0040.00418.09
8.2.10.0050.00319.22
8.2.00.0000.00819.24
8.1.330.0110.00821.97
8.1.320.0140.00516.27
8.1.310.0080.01216.61
8.1.300.0060.01217.99
8.1.290.0030.00630.84
8.1.280.0060.01025.92
8.1.270.0040.00418.70
8.1.260.0050.00326.35
8.1.250.0000.00728.09
8.1.240.0030.00619.15
8.1.230.0080.00322.11
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0060.00617.25
8.1.190.0060.00317.66
8.1.180.0070.00318.10
8.1.170.0040.00418.63
8.1.160.0000.01018.79
8.1.150.0000.00818.83
8.1.140.0000.00722.11
8.1.130.0070.00020.03
8.1.120.0000.00717.48
8.1.110.0000.00717.41
8.1.100.0000.00717.49
8.1.90.0000.00917.43
8.1.80.0030.00517.49
8.1.70.0000.00817.54
8.1.60.0040.00417.59
8.1.50.0000.00817.54
8.1.40.0040.00417.53
8.1.30.0040.00417.59
8.1.20.0060.00617.54
8.1.10.0080.00017.57
8.1.00.0000.00717.39
8.0.300.0020.00518.77
8.0.290.0040.00416.88
8.0.280.0040.00417.99
8.0.270.0000.00718.01
8.0.260.0000.00618.50
8.0.250.0040.00416.98
8.0.240.0000.00717.03
8.0.230.0000.00717.02
8.0.220.0080.00016.97
8.0.210.0040.00416.95
8.0.200.0070.00016.89
8.0.190.0000.00717.01
8.0.180.0000.00816.96
8.0.170.0030.00616.99
8.0.160.0050.00316.89
8.0.150.0000.00716.79
8.0.140.0000.00716.98
8.0.130.0060.00013.48
8.0.120.0050.00516.96
8.0.110.0040.00416.96
8.0.100.0030.00517.00
8.0.90.0000.00816.83
8.0.80.0170.00316.98
8.0.70.0040.00417.00
8.0.60.0000.00717.00
8.0.50.0000.00717.02
8.0.30.0100.01016.97
8.0.20.0150.00917.40
8.0.10.0030.00317.07
8.0.00.0110.00716.95
7.4.330.0000.00515.55
7.4.320.0030.00316.52
7.4.300.0060.00016.61
7.4.290.0030.00316.50
7.4.280.0000.00816.52
7.4.270.0000.00716.62
7.4.260.0000.00816.52
7.4.250.0030.00316.47
7.4.240.0000.00716.51
7.4.230.0030.00316.69
7.4.220.0080.00016.42
7.4.210.0100.00616.54
7.4.200.0070.00016.54
7.4.160.0090.00816.47
7.4.140.0100.01117.86
7.4.130.0130.01016.45
7.4.120.0110.00716.53
7.4.110.0120.00916.67
7.4.100.0070.01516.55
7.4.90.0080.01116.35
7.4.80.0110.01319.39
7.4.70.0120.00616.68
7.4.60.0170.00316.36
7.4.50.0030.00916.56
7.4.40.0110.00516.56
7.4.10.0170.00315.25
7.4.00.0060.00914.96
7.3.330.0020.00213.14
7.3.320.0030.00313.31
7.3.310.0000.00816.38
7.3.300.0000.00616.28
7.3.290.0070.00016.32
7.3.280.0140.00316.37
7.3.260.0120.00916.48
7.3.240.0120.00716.52
7.3.230.0090.00916.38
7.3.210.0120.01116.36
7.3.200.0130.00316.46
7.3.190.0100.00716.45
7.3.180.0080.01116.59
7.3.170.0120.00916.39
7.3.160.0140.00316.39
7.3.130.0120.00315.13
7.3.120.0070.01014.92
7.3.110.0110.00614.88
7.3.100.0070.00714.88
7.3.90.0000.01515.14
7.3.80.0060.00614.77
7.3.70.0100.00314.80
7.3.60.0070.00714.81
7.3.50.0040.00814.59
7.3.40.0080.00414.65
7.3.30.0000.01314.75
7.3.20.0100.00716.79
7.3.10.0050.01016.59
7.3.00.0090.00416.71
7.2.330.0070.01116.81
7.2.320.0110.00616.58
7.2.310.0030.01516.57
7.2.300.0120.00316.63
7.2.290.0150.00416.80
7.2.260.0060.01314.74
7.2.250.0070.01415.30
7.2.240.0060.00915.07
7.2.230.0030.01315.17
7.2.220.0120.00615.05
7.2.210.0000.01015.32
7.2.200.0040.00715.02
7.2.190.0000.01414.73
7.2.180.0040.00814.90
7.2.170.0030.01014.89
7.2.160.0090.00315.20
7.2.150.0100.00316.94
7.2.140.0040.00716.96
7.2.130.0110.00716.76
7.2.120.0060.01016.78
7.2.110.0110.00716.77
7.2.100.0060.01116.86
7.2.90.0080.00716.81
7.2.80.0110.00716.75
7.2.70.0120.00716.87
7.2.60.0100.00716.77
7.2.50.0090.00916.97
7.2.40.0070.00916.80
7.2.30.0070.00816.88
7.2.20.0050.00916.89
7.2.10.0080.00716.86
7.2.00.0040.01116.94
7.1.330.0030.00615.77
7.1.320.0130.00315.88
7.1.310.0070.00715.92
7.1.300.0040.01115.64
7.1.290.0030.01015.62
7.1.280.0030.00915.56
7.1.270.0060.00615.55
7.1.260.0030.00615.77
7.1.250.0080.00815.57
7.1.240.0050.00515.80
7.1.230.0000.01115.95
7.1.220.0000.01415.88
7.1.210.0080.00015.91
7.1.200.0060.00615.81
7.1.190.0030.01015.73
7.1.180.0040.00715.81
7.1.170.0030.01115.81
7.1.160.0070.00715.66
7.1.150.0110.00415.63
7.1.140.0030.00615.83
7.1.130.0080.00015.57
7.1.120.0030.01015.86
7.1.110.0030.01315.81
7.1.100.0060.00915.95
7.1.90.0070.01015.88
7.1.80.0100.00315.46
7.1.70.0090.00615.86
7.1.60.0130.00315.80
7.1.50.0090.00315.75
7.1.40.0110.00315.71
7.1.30.0000.01515.79
7.1.20.0070.01015.70
7.1.10.0070.01015.51
7.1.00.0030.01315.94
7.0.330.0050.00615.28
7.0.320.0070.00715.41
7.0.310.0040.00715.56
7.0.300.0000.01515.57
7.0.290.0000.01115.41
7.0.280.0090.00315.47
7.0.270.0040.00715.20
7.0.260.0100.00015.38
7.0.250.0070.00715.42
7.0.240.0030.00815.62
7.0.230.0000.01015.38
7.0.220.0090.00615.54
7.0.210.0070.00715.55
7.0.200.0070.00715.32
7.0.190.0070.00715.47
7.0.180.0000.01315.45
7.0.170.0060.00915.46
7.0.160.0090.00615.10
7.0.150.0060.00315.53
7.0.140.0030.00715.56
7.0.130.0030.01015.44
7.0.120.0000.00815.06
7.0.110.0000.01515.45
7.0.100.0090.00315.44
7.0.90.0080.00415.44
7.0.80.0040.01115.58
7.0.70.0030.01015.45
7.0.60.0070.00715.61
7.0.50.0060.00915.60
7.0.40.0070.00313.33
7.0.30.0070.00713.33
7.0.20.0100.00313.53
7.0.10.0030.00613.41
7.0.00.0030.01013.51
5.6.400.0090.00614.03
5.6.390.0070.00714.18
5.6.380.0100.00414.26
5.6.370.0060.00314.06
5.6.360.0030.01313.91
5.6.350.0070.00714.23
5.6.340.0030.01213.98
5.6.330.0040.00814.24
5.6.320.0080.00813.89
5.6.310.0080.00414.31
5.6.300.0000.00914.12
5.6.290.0090.00614.05
5.6.280.0000.01014.32
5.6.270.0070.00614.20
5.6.260.0040.00413.96
5.6.250.0100.00714.02
5.6.240.0030.00714.05
5.6.230.0000.01514.40
5.6.220.0070.01014.13
5.6.210.0030.00613.96
5.6.200.0070.00714.21
5.6.190.0060.00614.15
5.6.180.0060.00914.05
5.6.170.0040.01114.09
5.6.160.0080.00414.19
5.6.150.0070.01014.12
5.6.140.0040.00714.07
5.6.130.0090.00614.26
5.6.120.0060.00614.33
5.6.110.0030.01014.05
5.6.100.0060.00614.21
5.6.90.0060.00714.27
5.6.80.0030.01414.18
5.6.70.0110.00414.10
5.6.60.0120.00314.09
5.6.50.0120.00313.93
5.6.40.0060.00614.14
5.6.30.0040.01114.13
5.6.20.0080.00414.13
5.6.10.0120.00313.85
5.6.00.0090.00613.86

preferences:
27.89 ms | 403 KiB | 5 Q