3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $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($this->var); } public function add($value) { $this->var[$this->count++] = $value; } } /*$values = array('value 1','value 2','value 3');*/ $coll = new Mycollection($value); 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.60.0100.00616.88
8.3.50.0100.01216.40
8.3.40.0130.00318.58
8.3.30.0110.00418.67
8.3.20.0040.00418.68
8.3.10.0040.00420.52
8.3.00.0030.00919.06
8.2.180.0070.00716.63
8.2.170.0150.00022.96
8.2.160.0100.00320.35
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00419.48
8.2.110.0060.00321.01
8.2.100.0000.01217.91
8.2.90.0030.00519.30
8.2.80.0040.00419.28
8.2.70.0000.00817.63
8.2.60.0030.00518.04
8.2.50.0030.00518.07
8.2.40.0030.00518.05
8.2.30.0040.00417.98
8.2.20.0020.00517.64
8.2.10.0040.00417.91
8.2.00.0030.00617.91
8.1.280.0170.00325.92
8.1.270.0000.00824.66
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0030.00622.53
8.1.230.0080.00320.94
8.1.220.0000.00817.74
8.1.210.0060.00318.90
8.1.200.0040.00717.36
8.1.190.0000.00817.41
8.1.180.0060.00318.10
8.1.170.0060.00318.81
8.1.160.0040.00418.84
8.1.150.0000.00818.68
8.1.140.0030.00617.41
8.1.130.0070.00017.87
8.1.120.0040.00417.41
8.1.110.0070.00017.46
8.1.100.0070.00017.48
8.1.90.0070.00017.54
8.1.80.0040.00417.39
8.1.70.0000.00717.51
8.1.60.0070.00017.65
8.1.50.0040.00417.51
8.1.40.0040.00417.55
8.1.30.0030.00517.57
8.1.20.0050.00317.69
8.1.10.0000.00817.58
8.1.00.0080.00017.53
8.0.300.0000.00719.88
8.0.290.0000.00716.75
8.0.280.0040.00418.39
8.0.270.0030.00317.34
8.0.260.0030.00316.95
8.0.250.0040.00417.06
8.0.240.0040.00417.07
8.0.230.0030.00317.06
8.0.220.0000.00717.04
8.0.210.0050.00216.97
8.0.200.0030.00317.00
8.0.190.0050.00217.07
8.0.180.0040.00417.02
8.0.170.0000.00816.90
8.0.160.0000.00816.88
8.0.150.0050.00517.00
8.0.140.0030.00516.91
8.0.130.0050.00313.35
8.0.120.0040.00416.94
8.0.110.0030.00317.00
8.0.100.0050.00217.06
8.0.90.0040.00416.90
8.0.80.0000.01516.95
8.0.70.0080.00016.82
8.0.60.0020.00516.98
8.0.50.0040.00416.93
8.0.30.0060.01417.19
8.0.20.0130.00717.06
8.0.10.0050.00317.07
8.0.00.0130.00716.86
7.4.330.0000.00613.04
7.4.320.0040.00416.56
7.4.300.0090.00016.68
7.4.290.0000.00816.62
7.4.280.0000.00716.55
7.4.270.0000.00716.62
7.4.260.0030.00313.36
7.4.250.0040.00416.42
7.4.240.0040.00416.42
7.4.230.0070.00016.47
7.4.220.0090.00916.64
7.4.210.0080.00616.59
7.4.200.0030.00316.64
7.4.190.0000.00816.79
7.4.160.0150.00316.45
7.4.150.0060.01216.61
7.4.140.0050.01316.51
7.4.130.0090.00916.59
7.4.120.0120.00916.65
7.4.110.0060.01216.82
7.4.100.0090.00916.52
7.4.90.0160.00716.60
7.4.80.0070.01019.39
7.4.70.0070.01116.39
7.4.60.0130.00316.51
7.4.50.0070.00016.52
7.4.40.0090.00616.55
7.4.30.0110.00516.52
7.4.00.0080.00914.96
7.3.330.0030.00313.43
7.3.320.0050.00013.18
7.3.310.0050.00316.29
7.3.300.0030.00316.36
7.3.290.0130.00616.40
7.3.280.0070.00816.42
7.3.270.0030.01416.54
7.3.260.0130.00616.50
7.3.250.0120.01016.54
7.3.240.0080.00816.57
7.3.230.0000.01716.32
7.3.210.0120.00616.50
7.3.200.0070.01016.63
7.3.190.0140.00716.68
7.3.180.0080.00816.46
7.3.170.0030.01316.46
7.3.160.0000.01516.29
7.3.120.0080.00814.87
7.3.110.0080.00914.83
7.3.100.0120.00614.89
7.3.90.0070.00814.68
7.3.80.0050.00915.03
7.3.70.0030.01014.75
7.3.60.0070.00814.71
7.3.50.0060.00714.74
7.3.40.0040.00614.83
7.3.30.0090.00714.81
7.3.20.0060.00916.60
7.3.10.0050.00716.71
7.3.00.0040.00916.64
7.2.330.0070.01416.54
7.2.320.0130.01016.56
7.2.310.0100.01516.83
7.2.300.0060.01116.81
7.2.290.0090.00916.82
7.2.250.0100.00615.05
7.2.240.0080.00815.17
7.2.230.0070.00714.88
7.2.220.0060.00615.25
7.2.210.0030.00815.13
7.2.200.0020.01314.93
7.2.190.0050.00914.91
7.2.180.0070.00815.09
7.2.170.0010.00915.04
7.2.160.0030.00915.01
7.2.150.0030.00616.90
7.2.140.0050.00616.92
7.2.130.0090.00516.96
7.2.120.0050.01016.62
7.2.110.0070.00516.97
7.2.100.0070.00716.90
7.2.90.0030.01016.97
7.2.80.0100.00316.87
7.2.70.0070.00917.04
7.2.60.0080.00816.82
7.2.50.0090.00216.88
7.2.40.0050.00516.72
7.2.30.0030.01017.01
7.2.20.0050.01117.10
7.2.10.0100.00716.76
7.2.00.0070.00517.85
7.1.330.0110.00515.55
7.1.320.0060.00915.78
7.1.310.0080.00715.72
7.1.300.0030.01015.71
7.1.290.0070.00415.67
7.1.280.0050.00715.69
7.1.270.0090.00615.66
7.1.260.0060.00415.58
7.1.250.0050.00515.73
7.1.240.0050.00815.87
7.1.230.0030.01015.60
7.1.220.0030.01015.89
7.1.210.0060.00915.69
7.1.200.0030.00815.91
7.1.190.0070.00715.67
7.1.180.0060.00815.68
7.1.170.0020.01115.46
7.1.160.0030.00615.35
7.1.150.0050.00815.69
7.1.140.0050.01015.72
7.1.130.0090.00615.79
7.1.120.0060.00715.67
7.1.110.0090.00415.85
7.1.100.0040.00816.64
7.1.90.0020.01015.82
7.1.80.0080.00715.92
7.1.70.0040.00716.20
7.1.60.0100.00616.84
7.1.50.0080.00716.18
7.1.40.0080.00715.82
7.1.30.0060.00915.53
7.1.20.0100.00715.63
7.1.10.0080.00515.78
7.1.00.0070.02618.04
7.0.330.0060.00515.34
7.0.320.0020.01115.13
7.0.310.0050.00815.01
7.0.300.0090.00515.16
7.0.290.0080.00515.23
7.0.280.0080.00615.40
7.0.270.0030.01315.27
7.0.260.0070.00515.37
7.0.250.0070.00715.50
7.0.240.0070.00715.52
7.0.230.0030.01115.21
7.0.220.0040.00915.46
7.0.210.0080.00515.47
7.0.200.0250.01215.17
7.0.190.0050.00815.56
7.0.180.0030.00915.43
7.0.170.0100.00815.27
7.0.160.0070.00415.25
7.0.150.0070.00815.53
7.0.140.0080.02617.72
7.0.130.0060.00815.32
7.0.120.0040.02917.50
7.0.110.0060.00815.39
7.0.100.0010.01315.33
7.0.90.0030.00815.15
7.0.80.0050.00615.36
7.0.70.0040.01015.15
7.0.60.0080.03116.79
7.0.50.0040.03416.26
7.0.40.0090.01615.59
7.0.30.0140.01915.70
7.0.20.0130.02115.63
7.0.10.0090.02315.68
7.0.00.0050.03215.65
5.6.400.0060.00614.55
5.6.390.0050.00814.30
5.6.380.0030.01114.31
5.6.370.0080.00914.18
5.6.360.0050.00914.22
5.6.350.0020.01214.30
5.6.340.0050.01014.37
5.6.330.0070.01114.33
5.6.320.0110.00314.21
5.6.310.0080.00414.69
5.6.300.0050.00714.52
5.6.290.0030.00914.21
5.6.280.0040.03016.45
5.6.270.0060.00314.22
5.6.260.0070.00914.35
5.6.250.0080.00614.43
5.6.240.0030.01314.24
5.6.230.0070.00814.41
5.6.220.0080.00414.27
5.6.210.0090.02916.37
5.6.200.0050.02215.54
5.6.190.0070.02516.37
5.6.180.0090.02016.32
5.6.170.0130.02216.35
5.6.160.0090.01616.22
5.6.150.0060.03215.69
5.6.140.0050.01915.52
5.6.130.0040.02315.55
5.6.120.0050.02116.42
5.6.110.0040.03416.62
5.6.100.0080.03416.49
5.6.90.0090.01616.58
5.6.80.0060.01816.37
5.6.70.0130.03116.21
5.6.60.0090.00614.24
5.6.50.0090.00714.09
5.6.40.0020.01014.25
5.6.30.0050.01014.18
5.6.20.0070.00814.09
5.6.10.0080.00514.14
5.6.00.0040.00914.39
5.5.380.0090.00514.34
5.5.370.0030.01214.33
5.5.360.0050.01014.15
5.5.350.0150.02716.38
5.5.340.0070.02515.57
5.5.330.0090.02616.31
5.5.320.0110.03316.43
5.5.310.0130.01616.29
5.5.300.0060.03115.56
5.5.290.0030.03615.63
5.5.280.0080.03316.36
5.5.270.0030.02416.61
5.5.260.0060.02316.52
5.5.250.0080.02916.27
5.5.240.0070.03216.17
5.5.230.0030.01314.25
5.5.220.0030.00814.13
5.5.210.0030.01014.12
5.5.200.0120.00314.26
5.5.190.0030.01114.45
5.5.180.0050.00714.04
5.5.170.0030.01214.21
5.5.160.0030.01314.24
5.5.150.0090.00714.07
5.5.140.0040.01014.30
5.5.130.0080.00613.96
5.5.120.0000.01114.41
5.5.110.0130.00314.11
5.5.100.0050.00514.34
5.5.90.0020.01014.13
5.5.80.0050.01014.17
5.5.70.0020.01214.08
5.5.60.0050.00814.07
5.5.50.0100.00614.01
5.5.40.0060.00813.99
5.5.30.0050.00714.27
5.5.20.0050.00714.27
5.5.10.0100.00314.30
5.5.00.0050.00713.90
5.4.450.0040.02014.27
5.4.440.0070.01814.25
5.4.430.0050.02114.31
5.4.420.0030.03114.20
5.4.410.0050.01914.14
5.4.400.0050.02114.12
5.4.390.0020.02014.09
5.4.380.0050.01814.14
5.4.370.0060.02214.06
5.4.360.0040.01714.08
5.4.350.0050.01814.09
5.4.340.0070.02314.02
5.4.330.0030.00411.64
5.4.320.0070.02314.11
5.4.310.0060.02413.99
5.4.300.0100.01414.02
5.4.290.0050.03014.09
5.4.280.0070.02714.02
5.4.270.0070.02114.06
5.4.260.0040.02814.09
5.4.250.0070.02414.02
5.4.240.0040.02214.15
5.4.230.0050.02114.14
5.4.220.0070.02114.09
5.4.210.0070.02814.12
5.4.200.0030.03314.02
5.4.190.0060.01614.09
5.4.180.0040.02713.97
5.4.170.0030.03214.09
5.4.160.0040.02414.02
5.4.150.0060.02714.09
5.4.140.0040.02313.18
5.4.130.0040.02513.27
5.4.120.0060.03013.22
5.4.110.0080.02613.12
5.4.100.0080.01713.24
5.4.90.0050.01913.27
5.4.80.0030.02913.22
5.4.70.0050.01513.23
5.4.60.0060.01513.15
5.4.50.0030.01713.18
5.4.40.0050.01613.25
5.4.30.0040.01613.20
5.4.20.0050.01813.13
5.4.10.0070.02713.18
5.4.00.0070.01713.05
5.3.290.0060.01612.54
5.3.280.0040.03012.55
5.3.270.0040.02012.59
5.3.260.0080.02812.57
5.3.250.0090.02812.56
5.3.240.0040.02812.58
5.3.230.0070.02712.61
5.3.220.0070.02612.55
5.3.210.0030.02312.55
5.3.200.0030.02312.55
5.3.190.0050.03112.55
5.3.180.0060.02512.56
5.3.170.0040.02012.57
5.3.160.0060.01812.55
5.3.150.0070.02612.54
5.3.140.0090.01512.56
5.3.130.0050.02812.54
5.3.120.0030.02712.60
5.3.110.0060.02112.55
5.3.100.0040.02712.38
5.3.90.0060.01712.37
5.3.80.0060.02612.38
5.3.70.0030.02612.37
5.3.60.0060.02812.41
5.3.50.0010.03312.36
5.3.40.0020.02512.31
5.3.30.0110.01812.32
5.3.20.0040.02412.23
5.3.10.0090.02112.24
5.3.00.0070.02412.25
5.2.170.0000.06711.13
5.2.160.0030.06711.23
5.2.150.0070.06311.25
5.2.140.0070.04311.18
5.2.130.0070.06011.16
5.2.120.0070.06011.19
5.2.110.0030.06711.18
5.2.100.0070.06311.05
5.2.90.0030.06311.13
5.2.80.0100.04011.27
5.2.70.0000.05711.28
5.2.60.0030.04011.03
5.2.50.0070.06311.09
5.2.40.0070.05311.03
5.2.30.0030.05311.04
5.2.20.0070.04010.94
5.2.10.0070.03310.88
5.2.00.0070.03310.80
5.1.60.0070.05010.08
5.1.50.0030.05710.09
5.1.40.0030.05010.05
5.1.30.0030.04710.37
5.1.20.0100.05310.38
5.1.10.0130.03310.14
5.1.00.0030.05010.13
5.0.50.0100.0408.63
5.0.40.0000.0338.41
5.0.30.0070.0478.23
5.0.20.0070.0378.25
5.0.10.0070.0438.19
5.0.00.0070.0408.09
4.4.90.0000.0238.01
4.4.80.0100.0178.01
4.4.70.0000.0308.01
4.4.60.0030.0338.01
4.4.50.0030.0238.01
4.4.40.0000.0608.01
4.4.30.0000.0378.01
4.4.20.0000.0378.01
4.4.10.0070.0238.01
4.4.00.0030.0578.01
4.3.110.0030.0308.01
4.3.100.0030.0138.01
4.3.90.0030.0338.01
4.3.80.0030.0478.01
4.3.70.0030.0238.01
4.3.60.0030.0278.01
4.3.50.0000.0278.01
4.3.40.0070.0508.01
4.3.30.0000.0408.01
4.3.20.0030.0238.01
4.3.10.0000.0338.01
4.3.00.0000.0278.01

preferences:
50.96 ms | 401 KiB | 5 Q