3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public $var = array(1,2,3); public function __construct($array) { $var = array(1,2,3); if (is_array($array)) { $this->var = $array; } } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "valid: $var\n"; return $var; } } class MyCollection implements IteratorAggregate { private $count = 0; /* public function __construct($array) { $var = array(1,2,3); if (is_array($array)) { $this->var = $array; } } */ // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator(); } public function add($value) { $this->var[$this->count++] = $value; } } /*$values = array('value 1','value 2','value 3');*/ $coll = new Mycollection(); foreach ($coll as $key => $val) { echo "key/value: [$key -> $val]\n\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.40.0040.01118.79
8.3.30.0070.00718.78
8.3.20.0060.00318.45
8.3.10.0080.00021.10
8.3.00.0050.00319.69
8.2.170.0140.00322.96
8.2.160.0100.00320.35
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0000.00821.06
8.2.110.0050.00520.25
8.2.100.0040.00717.91
8.2.90.0050.00318.03
8.2.80.0050.00219.25
8.2.70.0030.00617.63
8.2.60.0000.00817.92
8.2.50.0030.00618.07
8.2.40.0040.00418.34
8.2.30.0000.00721.27
8.2.20.0050.00317.59
8.2.10.0000.00817.68
8.2.00.0080.00017.75
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0030.00622.01
8.1.230.0110.00020.85
8.1.220.0040.00417.74
8.1.210.0040.00418.85
8.1.200.0030.00617.25
8.1.190.0080.00017.64
8.1.180.0000.00818.10
8.1.170.0000.00818.38
8.1.160.0000.00718.79
8.1.150.0090.00018.68
8.1.140.0000.00717.47
8.1.130.0070.00017.78
8.1.120.0000.00817.51
8.1.110.0050.00317.52
8.1.100.0000.00717.47
8.1.90.0000.00817.38
8.1.80.0050.00317.42
8.1.70.0000.00717.44
8.1.60.0000.00817.58
8.1.50.0070.00017.42
8.1.40.0050.00317.45
8.1.30.0050.00217.57
8.1.20.0000.00817.54
8.1.10.0040.00417.46
8.1.00.0060.00317.51
8.0.300.0070.00020.09
8.0.290.0080.00017.18
8.0.280.0050.00218.43
8.0.270.0070.00017.22
8.0.260.0000.00716.95
8.0.250.0070.00316.96
8.0.240.0040.00417.02
8.0.230.0000.00717.03
8.0.220.0070.00316.98
8.0.210.0040.00416.99
8.0.200.0030.00317.01
8.0.190.0030.00616.98
8.0.180.0000.00816.91
8.0.170.0090.00016.95
8.0.160.0070.00316.93
8.0.150.0000.00716.95
8.0.140.0040.00416.94
8.0.130.0000.00713.45
8.0.120.0040.00416.96
8.0.110.0040.00417.02
8.0.100.0000.00717.01
8.0.90.0050.00317.09
8.0.80.0030.01216.93
8.0.70.0020.00516.87
8.0.60.0000.00816.99
8.0.50.0020.00516.91
8.0.30.0110.00817.04
8.0.20.0130.00717.40
8.0.10.0030.00617.16
8.0.00.0080.00816.75
7.4.330.0000.00616.69
7.4.320.0000.00616.63
7.4.300.0030.00316.55
7.4.290.0000.00716.46
7.4.280.0080.00016.54
7.4.270.0030.00316.52
7.4.260.0030.00313.18
7.4.250.0030.00316.60
7.4.240.0080.00016.47
7.4.230.0050.00216.56
7.4.220.0090.00916.61
7.4.210.0100.00716.56
7.4.200.0030.00316.63
7.4.190.0000.00816.67
7.4.160.0100.00716.54
7.4.150.0090.00917.40
7.4.140.0160.01317.86
7.4.130.0040.01316.52
7.4.120.0090.00816.60
7.4.110.0100.00716.45
7.4.100.0070.01416.40
7.4.90.0130.00916.47
7.4.80.0070.01319.39
7.4.70.0090.01216.47
7.4.60.0080.00916.71
7.4.50.0040.00416.12
7.4.40.0100.00322.77
7.4.30.0070.01016.52
7.4.00.0090.00915.20
7.3.330.0050.00013.40
7.3.320.0000.00513.23
7.3.310.0040.00316.48
7.3.300.0040.00416.38
7.3.290.0060.00916.39
7.3.280.0070.00916.37
7.3.270.0070.01017.40
7.3.260.0130.00918.24
7.3.250.0140.00416.42
7.3.240.0130.00316.37
7.3.230.0160.00916.52
7.3.210.0150.00916.48
7.3.200.0100.01319.39
7.3.190.0080.01416.49
7.3.180.0170.00016.54
7.3.170.0090.00616.57
7.3.160.0090.00616.30
7.3.120.0110.00415.03
7.3.00.0070.00716.59
7.2.330.0100.00716.82
7.2.320.0070.01316.69
7.2.310.0040.01416.77
7.2.300.0120.00816.69
7.2.290.0090.01216.65
7.2.130.0060.00917.00
7.2.120.0000.01716.89
7.2.110.0090.00616.90
7.2.100.0060.00916.84
7.2.90.0060.00616.70
7.2.80.0070.00716.83
7.2.70.0030.00716.96
7.2.60.0090.00516.97
7.2.50.0060.01016.85
7.2.40.0030.01217.01
7.2.30.0030.01317.05
7.2.20.0090.00916.91
7.2.10.0060.00916.70
7.2.00.0030.01016.89
7.1.250.0070.00715.59
7.1.240.0040.00815.81
7.1.230.0030.01015.70
7.1.220.0080.00415.84
7.1.210.0100.00615.57
7.1.200.0020.01215.71
7.1.190.0000.01415.81
7.1.180.0030.01015.67
7.1.170.0030.00615.75
7.1.160.0090.00615.85
7.1.150.0030.01115.55
7.1.140.0090.00615.59
7.1.130.0050.00515.67
7.1.120.0120.00315.66
7.1.110.0030.01015.66
7.1.100.0090.00315.56
7.1.90.0070.00715.50
7.1.80.0030.01215.65
7.1.70.0020.01016.32
7.1.60.0100.00416.47
7.1.50.0020.01116.25
7.1.40.0070.00715.93
7.1.30.0050.01116.19
7.1.20.0050.01316.17
7.1.10.0020.00716.13
7.1.00.0050.00616.19
7.0.330.0070.00715.45
7.0.320.0030.01315.50
7.0.310.0030.00615.29
7.0.300.0100.00315.24
7.0.290.0040.00815.29
7.0.280.0070.00715.36
7.0.270.0090.00615.53
7.0.260.0060.00915.45
7.0.250.0090.00315.43
7.0.240.0080.00415.36
7.0.230.0040.00415.13
7.0.220.0060.00615.38
7.0.210.0040.00815.55
7.0.200.0070.00515.99
7.0.190.0030.00816.01
7.0.180.0040.00715.82
7.0.170.0060.00715.78
7.0.160.0040.00515.91
7.0.150.0050.00515.90
7.0.140.0050.00716.01
7.0.130.0030.00916.06
7.0.120.0060.00615.92
7.0.110.0040.00715.91
7.0.100.0060.00415.77
7.0.90.0030.00815.88
7.0.80.0050.00716.07
7.0.70.0060.00415.93
7.0.60.0040.01215.83
7.0.50.0050.00715.98
7.0.40.0080.00514.16
7.0.30.0040.00714.10
7.0.20.0060.00814.18
7.0.10.0050.00814.29
7.0.00.0070.00514.25
5.6.380.0030.01314.19
5.6.370.0000.01414.41
5.6.360.0080.00414.59
5.6.350.0100.00314.51
5.6.340.0060.00914.50
5.6.330.0060.00314.12
5.6.320.0030.00914.42
5.6.310.0100.00314.16
5.6.300.0070.02317.71
5.6.290.0090.02117.62
5.6.280.0040.02517.62
5.6.270.0070.04717.79
5.6.260.0030.03117.73
5.6.250.0070.02317.57
5.6.240.0040.02717.63
5.6.230.0010.02717.44
5.6.220.0050.02317.70
5.6.210.0070.03817.61
5.6.200.0050.03317.73
5.6.190.0040.02717.62
5.6.180.0080.04217.87
5.6.170.0030.02417.66
5.6.160.0050.02617.69
5.6.150.0050.02617.71
5.6.140.0000.03117.55
5.6.130.0080.02117.73
5.6.120.0020.02917.56
5.6.110.0050.02717.59
5.6.100.0050.02817.57
5.6.90.0050.02817.60
5.6.80.0110.01717.26
5.6.70.0050.02917.38
5.6.60.0030.03617.27
5.6.50.0100.02217.29
5.6.40.0100.02217.24
5.6.30.0050.03017.27
5.6.20.0070.02017.45
5.6.10.0100.02317.37
5.6.00.0070.02517.19
5.5.380.0050.02114.42
5.5.370.0000.02914.37
5.5.360.0050.04414.34
5.5.350.0050.02014.43
5.5.340.0060.01914.72
5.5.330.0050.02514.63
5.5.320.0000.02414.64
5.5.310.0120.02614.62
5.5.300.0050.02114.65
5.5.290.0050.02314.63
5.5.280.0030.03214.63
5.5.270.0070.02314.59
5.5.260.0090.02014.70
5.5.250.0050.02514.43
5.5.240.0030.03614.21
5.5.230.0100.02614.14
5.5.220.0070.02314.34
5.5.210.0050.02214.36
5.5.200.0040.02414.31
5.5.190.0020.02714.36
5.5.180.0020.02914.31
5.5.170.0040.00711.18
5.5.160.0060.02014.36
5.5.150.0050.02614.30
5.5.140.0050.02114.18
5.5.130.0060.02514.30
5.5.120.0060.02414.30
5.5.110.0080.01814.33
5.5.100.0050.03814.25
5.5.90.0020.02514.25
5.5.80.0000.02414.22
5.5.70.0110.01814.31
5.5.60.0120.01714.14
5.5.50.0030.02414.25
5.5.40.0020.03314.13
5.5.30.0060.02214.27
5.5.20.0040.02614.08
5.5.10.0050.01914.27
5.5.00.0050.02314.29
5.4.450.0070.02815.26
5.4.440.0020.02415.20
5.4.430.0100.02415.20
5.4.420.0050.02415.35
5.4.410.0040.02515.20
5.4.400.0080.02615.13
5.4.390.0030.02315.17
5.4.380.0050.02515.08
5.4.370.0070.01915.16
5.4.360.0030.02715.13
5.4.350.0030.02615.18
5.4.340.0060.02315.09
5.4.330.0040.00711.18
5.4.320.0030.02615.01
5.4.310.0100.02215.05
5.4.300.0050.02315.07
5.4.290.0030.02315.03
5.4.280.0080.02315.09
5.4.270.0070.02015.18
5.4.260.0000.03415.08
5.4.250.0100.01915.04
5.4.240.0050.03015.05
5.4.230.0040.02215.09
5.4.220.0110.02415.07
5.4.210.0030.02715.17
5.4.200.0080.02015.05
5.4.190.0070.02115.12
5.4.180.0030.02715.12
5.4.170.0090.01915.12
5.4.160.0040.02415.03
5.4.150.0020.02815.01
5.4.140.0030.02213.98
5.4.130.0030.02213.92
5.4.120.0070.02713.84
5.4.110.0080.02113.86
5.4.100.0020.02113.79
5.4.90.0070.02413.75
5.4.80.0030.02213.93
5.4.70.0040.02413.93
5.4.60.0090.01813.89
5.4.50.0040.02913.92
5.4.40.0070.02313.81
5.4.30.0030.02513.78
5.4.20.0070.02113.91
5.4.10.0060.02013.90
5.4.00.0100.02513.54
5.3.290.0030.02513.06
5.3.280.0030.02313.06
5.3.270.0050.02213.06
5.3.260.0030.02213.06
5.3.250.0040.03513.06
5.3.240.0000.02813.06
5.3.230.0070.01913.06
5.3.220.0060.02013.06
5.3.210.0030.02213.06
5.3.200.0020.02713.06
5.3.190.0060.01913.06
5.3.180.0030.03213.06
5.3.170.0030.02813.06
5.3.160.0030.02213.06
5.3.150.0080.02013.06
5.3.140.0030.02313.06
5.3.130.0070.02613.06
5.3.120.0050.02413.06
5.3.110.0020.02313.06
5.3.100.0030.03913.06
5.3.90.0060.03113.06
5.3.80.0030.02813.06
5.3.70.0020.02413.06
5.3.60.0070.01813.06
5.3.50.0000.02513.06
5.3.40.0020.02213.06
5.3.30.0050.04013.06
5.3.20.0040.02013.06
5.3.10.0070.02313.06
5.3.00.0050.02013.06
5.2.170.0020.02013.06
5.2.160.0040.01713.06
5.2.150.0030.01913.06
5.2.140.0030.01913.06
5.2.130.0060.03413.06
5.2.120.0030.01813.06
5.2.110.0020.01913.06
5.2.100.0050.01913.06
5.2.90.0030.02413.06
5.2.80.0080.02313.06
5.2.70.0020.02013.06
5.2.60.0020.02413.06
5.2.50.0050.02113.06
5.2.40.0000.02213.06
5.2.30.0050.01713.06
5.2.20.0060.01613.06
5.2.10.0050.03613.06
5.2.00.0100.02213.06
5.1.60.0030.01313.06
5.1.50.0050.01213.06
5.1.40.0040.01313.06
5.1.30.0020.01913.06
5.1.20.0020.02113.06
5.1.10.0040.02213.06
5.1.00.0030.01413.06
5.0.50.0020.01613.06
5.0.40.0040.00913.06
5.0.30.0070.02713.06
5.0.20.0050.02413.06
5.0.10.0000.01813.06
5.0.00.0020.02113.06
4.4.90.0020.01013.06
4.4.80.0050.00713.06
4.4.70.0020.00913.06
4.4.60.0020.00913.06
4.4.50.0020.01313.06
4.4.40.0030.01413.06
4.4.30.0030.01313.06
4.4.20.0020.01213.06
4.4.10.0030.01013.06
4.4.00.0040.01413.06
4.3.110.0020.01513.06
4.3.100.0070.01513.06
4.3.90.0010.01613.06
4.3.80.0030.01413.06
4.3.70.0020.00913.06
4.3.60.0020.00913.06
4.3.50.0020.01113.06
4.3.40.0020.01313.06
4.3.30.0000.01013.06
4.3.20.0040.00713.06
4.3.10.0000.01213.06
4.3.00.0000.01113.06

preferences:
47.75 ms | 400 KiB | 5 Q