3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BadIterator implements Iterator { private $data = [1, 2, 3, 4, 5]; private $pos = 0; public function current() { return $this; } public function key() { return $this->pos; } public function next() { $this->pos++; } public function rewind() { $this->pos = 0; } public function valid() { return $this->pos < count($this->data); } public function __toString() { return (string) $this->data[$this->pos]; } } echo "Direct iteration:\n"; foreach (new BadIterator as $val) { echo "$val\n"; } echo "Caching iteration:\n"; foreach (new CachingIterator(new BadIterator) as $val) { echo "$val\n"; }

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.0120.00318.35
8.3.50.0120.00317.98
8.3.40.0120.00918.92
8.3.30.0140.00418.84
8.3.20.0080.00019.10
8.3.10.0000.00923.52
8.3.00.0040.00422.42
8.2.180.0150.00018.68
8.2.170.0070.00722.96
8.2.160.0110.00421.09
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00421.18
8.2.110.0070.00321.00
8.2.100.0090.00317.84
8.2.90.0090.00218.09
8.2.80.0060.00317.97
8.2.70.0000.00818.05
8.2.60.0060.00318.34
8.2.50.0050.00318.10
8.2.40.0000.00821.20
8.2.30.0070.00020.64
8.2.20.0030.00518.02
8.2.10.0050.00218.15
8.2.00.0030.00319.48
8.1.280.0070.01025.92
8.1.270.0050.00322.19
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00322.64
8.1.230.0070.00321.02
8.1.220.0030.00517.74
8.1.210.0040.00418.96
8.1.200.0040.00417.35
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0040.00418.69
8.1.160.0000.00718.84
8.1.150.0050.00218.95
8.1.140.0030.00519.02
8.1.130.0040.00419.03
8.1.120.0070.00017.49
8.1.110.0040.00417.39
8.1.100.0030.00617.49
8.1.90.0070.00417.47
8.1.80.0030.00617.42
8.1.70.0030.00317.50
8.1.60.0090.00017.62
8.1.50.0000.00717.45
8.1.40.0060.00317.55
8.1.30.0040.00417.56
8.1.20.0030.01017.52
8.1.10.0080.00017.63
8.1.00.0040.00417.57
8.0.300.0070.00019.94
8.0.290.0040.00416.75
8.0.280.0030.00318.50
8.0.270.0000.00716.90
8.0.260.0000.00818.65
8.0.250.0100.00016.98
8.0.240.0030.00317.02
8.0.230.0000.00717.07
8.0.220.0030.00616.87
8.0.210.0000.00716.90
8.0.200.0080.00017.07
8.0.190.0000.00817.07
8.0.180.0000.00816.93
8.0.170.0000.00816.95
8.0.160.0030.00716.94
8.0.150.0000.00816.89
8.0.140.0000.00716.95
8.0.130.0030.00313.37
8.0.120.0080.00016.85
8.0.110.0040.00417.00
8.0.100.0070.00016.77
8.0.90.0000.00716.93
8.0.80.0070.00916.99
8.0.70.0000.00816.88
8.0.60.0000.00816.93
8.0.50.0070.00017.04
8.0.30.0070.01117.21
8.0.20.0120.00817.40
8.0.10.0000.00716.91
8.0.00.0120.00916.89
7.4.330.0020.00215.55
7.4.320.0030.00316.50
7.4.300.0030.00316.46
7.4.290.0000.00716.61
7.4.280.0050.00316.51
7.4.270.0070.00016.63
7.4.260.0050.00316.41
7.4.250.0030.00316.43
7.4.240.0030.00316.62
7.4.230.0000.00716.50
7.4.220.0040.00416.63
7.4.210.0060.01116.57
7.4.200.0070.00016.55
7.4.160.0070.01016.46
7.4.140.0110.00917.86
7.4.130.0110.00816.56
7.4.120.0120.00916.50
7.4.110.0060.01016.59
7.4.100.0070.01416.56
7.4.90.0100.01316.47
7.4.80.0210.00419.39
7.4.70.0030.01916.57
7.4.60.0090.01216.41
7.4.50.0080.00616.46
7.4.40.0110.01216.41
7.4.00.0070.01015.09
7.3.330.0030.00313.36
7.3.320.0000.00613.43
7.3.310.0030.00316.48
7.3.300.0080.00316.34
7.3.290.0000.00716.30
7.3.280.0060.01216.40
7.3.260.0080.01016.53
7.3.240.0110.00816.60
7.3.230.0090.00916.50
7.3.210.0070.01016.53
7.3.200.0070.01316.41
7.3.190.0160.00016.50
7.3.180.0110.00616.34
7.3.170.0080.00816.40
7.3.160.0110.01216.54
7.3.120.0030.01014.91
7.3.110.0090.00815.06
7.3.100.0040.01114.91
7.3.90.0060.00514.89
7.3.80.0040.00714.78
7.3.70.0070.00414.99
7.3.60.0080.00714.89
7.3.50.0090.00414.94
7.3.40.0060.01214.63
7.3.30.0040.01414.69
7.3.20.0070.00516.68
7.3.10.0030.01116.53
7.3.00.0060.00916.63
7.2.330.0100.01016.75
7.2.320.0040.01616.52
7.2.310.0070.01016.48
7.2.300.0100.01016.75
7.2.290.0110.00616.71
7.2.250.0020.01615.31
7.2.240.0120.00515.06
7.2.230.0030.00915.02
7.2.220.0050.00715.33
7.2.210.0080.00714.92
7.2.200.0080.00615.01
7.2.190.0050.00914.88
7.2.180.0080.00514.70
7.2.170.0030.01515.08
7.2.130.0090.00616.94
7.2.120.0110.00316.96
7.2.110.0070.00717.02
7.2.100.0030.01016.98
7.2.90.0030.00916.78
7.2.80.0200.00915.50
7.2.70.0440.00715.63
7.2.60.0390.00915.71
7.2.50.0470.00715.74
7.2.40.0220.00915.75
7.2.30.0220.00715.68
7.2.20.0330.00615.70
7.2.10.0300.01415.82
7.2.00.0260.00815.64
7.1.330.0050.01015.78
7.1.320.0030.00615.72
7.1.310.0060.00815.91
7.1.300.0050.00815.63
7.1.290.0080.00815.63
7.1.280.0070.00815.73
7.1.270.0050.00815.79
7.1.260.0110.00515.73
7.1.250.0100.00615.86
7.1.200.0320.00513.94
7.1.190.0600.00813.89
7.1.180.0300.00813.81
7.1.170.0620.00313.70
7.1.160.0680.00513.67
7.1.150.0310.00613.87
7.1.140.0610.00713.90
7.1.130.0340.00913.91
7.1.120.0260.01213.79
7.1.110.0780.01113.83
7.1.100.0600.00513.76
7.1.90.0270.00613.47
7.1.80.0380.00413.56
7.1.70.0570.00613.55
7.1.60.0880.01331.78
7.1.50.0750.01031.51
7.1.40.0710.01231.43
7.1.30.0710.01031.37
7.1.20.0760.01031.52
7.1.10.0620.00713.65
7.1.00.0570.00513.82
7.0.310.0290.00513.54
7.0.300.0650.00713.59
7.0.290.0870.01313.69
7.0.280.0330.00813.61
7.0.270.0150.00513.57
7.0.260.0640.00713.36
7.0.250.0700.00013.76
7.0.240.0840.00613.68
7.0.230.0770.00713.80
7.0.220.0130.00613.53
7.0.210.0880.01013.33
7.0.200.0570.01113.52
7.0.190.0560.00613.50
7.0.180.0570.00313.40
7.0.170.0570.01413.53
7.0.160.1190.00713.80
7.0.150.0460.01113.71
7.0.140.0550.00013.67
7.0.130.0420.01913.60
7.0.120.0530.00713.54
7.0.110.0710.01113.54
7.0.100.0770.00013.80
7.0.90.0580.01113.73
7.0.80.0540.00713.69
7.0.70.0510.00413.63
7.0.60.0790.00313.66
7.0.50.0460.00913.66
7.0.40.0470.00313.74
7.0.30.0520.00713.53
7.0.20.0640.00913.50
7.0.10.0400.00713.64
7.0.00.0410.01013.66
5.6.300.0170.00014.03
5.6.290.0120.00814.66
5.6.280.0070.01614.61
5.6.270.0060.01814.61
5.6.260.0090.01214.54
5.6.250.0100.01014.39
5.6.240.0130.01314.44
5.6.230.0060.01514.41
5.6.220.0110.01114.35
5.6.210.0100.01314.23
5.6.200.0120.01014.63
5.6.190.0080.01114.51
5.6.180.0160.00714.45
5.6.170.0200.00314.59
5.6.160.0140.00914.14
5.6.150.0100.01314.25
5.6.140.0160.00514.52
5.6.130.0110.01114.33
5.6.120.0160.00414.64
5.6.110.0070.01414.12
5.6.100.0150.00314.38
5.6.90.0150.00614.52
5.6.80.0120.00714.41
5.6.70.0080.01414.22
5.6.60.0060.01214.24
5.6.50.0110.00814.61
5.6.40.0130.01314.44
5.6.30.0150.01014.23
5.6.20.0120.00614.33
5.6.10.0130.00714.54
5.6.00.0200.00314.16
5.5.380.0080.00810.95
5.5.370.0070.00711.14
5.5.360.0110.00411.51
5.5.350.0110.00411.25
5.5.340.0060.00911.32
5.5.330.0110.00311.29
5.5.320.0090.00911.36
5.5.310.0110.00711.45
5.5.300.0160.00010.96
5.5.290.0080.00811.27
5.5.280.0100.00511.16
5.5.270.0080.00311.30
5.5.260.0140.00011.25
5.5.250.0100.00711.27
5.5.240.0140.00310.86
5.5.230.0040.00811.25
5.5.220.0080.00411.25
5.5.210.0000.01311.27
5.5.200.0130.00311.09
5.5.190.0100.00311.14
5.5.180.0130.00310.96
5.5.170.0150.00414.43
5.5.160.0100.00511.11
5.5.150.0110.00311.38
5.5.140.0080.00311.14
5.5.130.0050.01011.14
5.5.120.0100.00711.22
5.5.110.0120.00311.19
5.5.100.0080.00411.21
5.5.90.0060.00611.09
5.5.80.0080.00410.84
5.5.70.0080.00610.96
5.5.60.0150.00011.36
5.5.50.0080.00511.10
5.5.40.0110.00011.35
5.5.30.0180.00011.33
5.5.20.0080.00311.39
5.5.10.0040.01211.29
5.5.00.0120.00411.19
5.4.450.0110.00011.48
5.4.440.0070.00711.33
5.4.430.0160.00011.19
5.4.420.0110.00511.19
5.4.410.0040.00911.23
5.4.400.0100.00710.89
5.4.390.0130.00011.21
5.4.380.0070.00711.36
5.4.370.0070.01010.82
5.4.360.0090.00511.41
5.4.350.0000.01211.29
5.4.340.0100.00310.95
5.4.330.0000.01211.07
5.4.320.0080.00810.85
5.4.310.0050.00610.93
5.4.300.0070.00711.35
5.4.290.0140.00011.36
5.4.280.0100.00711.16
5.4.270.0140.00510.97
5.4.260.0040.00911.06
5.4.250.0060.00911.32
5.4.240.0060.01011.39
5.4.230.0030.00911.27
5.4.220.0070.00711.26
5.4.210.0060.01211.03
5.4.200.0080.00811.33
5.4.190.0140.00011.02
5.4.180.0110.00610.93
5.4.170.0090.00610.81
5.4.160.0060.00911.19
5.4.150.0000.01311.32
5.4.140.0090.00510.95
5.4.130.0120.00411.40
5.4.120.0130.00311.28
5.4.110.0050.00611.04
5.4.100.0160.00010.83
5.4.90.0130.00411.18
5.4.80.0120.00010.96
5.4.70.0150.00311.17
5.4.60.0110.00411.11
5.4.50.0050.01011.27
5.4.40.0120.00010.97
5.4.30.0070.00411.32
5.4.20.0070.00711.20
5.4.10.0110.00411.23
5.4.00.0090.00311.04
5.3.290.0090.00610.39
5.3.280.0030.00910.29
5.3.270.0180.00010.33
5.3.260.0080.00610.24
5.3.250.0070.00510.30
5.3.240.0120.00010.12
5.3.230.0120.00010.23
5.3.220.0090.0069.94
5.3.210.0120.00310.21
5.3.200.0030.01210.06
5.3.190.0110.00310.32
5.3.180.0110.00010.37
5.3.170.0100.00510.46
5.3.160.0060.00610.25
5.3.150.0060.00610.31
5.3.140.0090.00410.06
5.3.130.0050.00510.34
5.3.120.0120.00310.41
5.3.110.0110.00510.18
5.3.100.0050.00910.39
5.3.90.0100.00310.45
5.3.80.0090.00610.35
5.3.70.0090.00410.24
5.3.60.0140.00510.29
5.3.50.0060.01110.05
5.3.40.0060.00610.26
5.3.30.0080.00810.14
5.3.20.0120.00410.25
5.3.10.0120.00310.12
5.3.00.0100.00010.06
5.2.170.0080.0039.38
5.2.160.0100.0009.26
5.2.150.0000.0139.30
5.2.140.0070.0029.27
5.2.130.0000.0109.26
5.2.120.0070.0059.26
5.2.110.0080.0049.26
5.2.100.0130.0029.26
5.2.90.0070.0029.26
5.2.80.0050.0059.27
5.2.70.0120.0009.26
5.2.60.0110.0009.26
5.2.50.0040.0069.26
5.2.40.0090.0039.26
5.2.30.0090.0049.26
5.2.20.0100.0009.26
5.2.10.0040.0089.26
5.2.00.0100.0009.26
5.1.60.0030.0069.26
5.1.50.0080.0009.26
5.1.40.0020.0059.26
5.1.30.0090.0029.26
5.1.20.0030.0079.26
5.1.10.0000.0119.26
5.1.00.0080.0049.26
5.0.50.0040.0049.26
5.0.40.0060.0039.26
5.0.30.0090.0009.26
5.0.20.0040.0049.26
5.0.10.0040.0049.26
5.0.00.0080.0059.26
4.4.90.0070.0029.26
4.4.80.0000.0059.26
4.4.70.0000.0069.26
4.4.60.0000.0079.26
4.4.50.0000.0079.26
4.4.40.0000.0079.26
4.4.30.0070.0029.26
4.4.20.0060.0009.26
4.4.10.0000.0079.26
4.4.00.0030.0059.26
4.3.110.0090.0009.26
4.3.100.0040.0049.26
4.3.90.0040.0049.26
4.3.80.0060.0009.26
4.3.70.0000.0079.26
4.3.60.0030.0039.26
4.3.50.0000.0069.26
4.3.40.0050.0029.26
4.3.30.0060.0039.26
4.3.20.0000.0059.26
4.3.10.0060.0039.26
4.3.00.0060.0009.26

preferences:
65.05 ms | 401 KiB | 5 Q