3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public static $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(); 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.0120.00318.97
8.3.30.0030.01518.80
8.3.20.0040.00420.29
8.3.10.0040.00421.97
8.3.00.0030.00522.47
8.2.170.0120.00322.96
8.2.160.0080.00620.74
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0070.00026.16
8.2.120.0060.00319.36
8.2.110.0060.00321.98
8.2.100.0040.00717.91
8.2.90.0000.00819.05
8.2.80.0040.00418.05
8.2.70.0040.00417.75
8.2.60.0080.00017.68
8.2.50.0090.00018.07
8.2.40.0030.00618.34
8.2.30.0030.00618.10
8.2.20.0000.00717.76
8.2.10.0060.00317.77
8.2.00.0030.00517.89
8.1.270.0120.00322.25
8.1.260.0080.00026.35
8.1.250.0070.00728.09
8.1.240.0060.00323.92
8.1.230.0040.00719.09
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0030.00617.23
8.1.190.0000.00817.64
8.1.180.0040.00418.10
8.1.170.0080.00018.68
8.1.160.0000.00721.92
8.1.150.0080.00018.71
8.1.140.0040.00417.37
8.1.130.0030.00317.91
8.1.120.0040.00417.53
8.1.110.0060.00317.48
8.1.100.0000.00717.38
8.1.90.0000.00717.52
8.1.80.0030.00517.46
8.1.70.0000.00717.46
8.1.60.0000.00917.63
8.1.50.0040.00417.54
8.1.40.0100.00017.52
8.1.30.0050.00317.74
8.1.20.0090.00017.66
8.1.10.0040.00417.52
8.1.00.0030.00617.44
8.0.300.0040.00418.77
8.0.290.0030.00517.40
8.0.280.0000.00718.49
8.0.270.0040.00417.30
8.0.260.0040.00416.85
8.0.250.0000.00717.07
8.0.240.0000.00717.07
8.0.230.0000.00717.04
8.0.220.0070.00016.84
8.0.210.0030.00516.87
8.0.200.0000.00616.96
8.0.190.0070.00016.95
8.0.180.0000.00716.91
8.0.170.0040.00416.94
8.0.160.0070.00016.98
8.0.150.0040.00316.96
8.0.140.0050.00316.84
8.0.130.0050.00013.41
8.0.120.0030.00516.85
8.0.110.0030.00516.98
8.0.100.0080.00016.80
8.0.90.0040.00416.96
8.0.80.0060.01517.02
8.0.70.0000.00817.05
8.0.60.0040.00417.04
8.0.50.0040.00416.95
8.0.30.0150.00817.19
8.0.20.0060.01417.40
8.0.10.0040.00416.89
8.0.00.0110.01016.67
7.4.330.0000.00515.12
7.4.320.0000.00616.63
7.4.300.0000.00616.49
7.4.290.0030.00316.63
7.4.280.0030.00316.64
7.4.270.0070.00016.54
7.4.260.0000.00716.43
7.4.250.0070.00016.53
7.4.240.0030.00416.67
7.4.230.0070.00016.62
7.4.220.0120.00316.54
7.4.210.0070.00816.63
7.4.200.0030.00316.41
7.4.190.0050.00216.77
7.4.160.0070.01016.61
7.4.150.0060.01417.40
7.4.140.0120.00517.86
7.4.130.0130.00516.48
7.4.120.0070.01116.48
7.4.110.0170.00716.63
7.4.100.0070.01016.50
7.4.90.0090.01016.66
7.4.80.0090.01219.39
7.4.70.0120.00316.55
7.4.60.0060.00916.59
7.4.50.0000.00416.29
7.4.40.0070.01122.77
7.4.30.0080.00916.71
7.4.10.0070.01014.97
7.4.00.0060.01015.14
7.3.330.0020.00213.44
7.3.320.0000.00813.22
7.3.310.0000.00716.14
7.3.300.0000.00716.38
7.3.290.0140.00016.39
7.3.280.0090.00816.35
7.3.270.0030.01317.40
7.3.260.0120.01216.55
7.3.250.0100.00716.31
7.3.240.0110.00516.51
7.3.230.0140.00316.39
7.3.210.0110.00616.45
7.3.200.0120.00619.39
7.3.190.0100.00716.50
7.3.180.0140.00316.54
7.3.170.0130.00316.55
7.3.160.0080.00916.42
7.3.130.0090.00615.02
7.3.120.0100.00714.79
7.3.110.0080.01014.91
7.3.100.0050.01114.79
7.3.90.0050.00914.94
7.3.80.0010.01314.74
7.3.70.0030.00914.94
7.3.60.0050.00814.75
7.3.50.0080.00514.86
7.3.40.0050.01014.66
7.3.30.0050.00814.84
7.3.20.0070.00516.76
7.3.10.0080.00816.52
7.3.00.0090.00616.49
7.2.330.0070.01016.86
7.2.320.0090.01216.40
7.2.310.0080.00816.82
7.2.300.0040.01316.82
7.2.290.0000.01716.64
7.2.260.0040.01515.10
7.2.250.0130.00514.86
7.2.240.0070.00915.12
7.2.230.0050.01115.12
7.2.220.0050.01015.20
7.2.210.0070.01015.02
7.2.200.0090.00414.98
7.2.190.0000.01215.11
7.2.180.0050.00815.07
7.2.170.0070.00715.05
7.2.160.0020.01615.06
7.2.150.0070.00716.91
7.2.140.0060.00916.97
7.2.130.0080.01016.69
7.2.120.0070.00816.62
7.2.110.0100.00516.86
7.2.100.0080.00616.68
7.2.90.0130.00616.86
7.2.80.0100.00616.72
7.2.70.0120.00516.75
7.2.60.0070.00716.68
7.2.50.0110.00916.82
7.2.40.0070.00716.70
7.2.30.0080.00816.80
7.2.20.0110.00716.51
7.2.10.0100.00816.84
7.2.00.0050.01017.48
7.1.330.0070.00815.59
7.1.320.0080.00915.85
7.1.310.0040.00915.71
7.1.300.0090.00715.71
7.1.290.0050.00615.71
7.1.280.0040.01115.98
7.1.270.0070.00915.77
7.1.260.0050.00815.63
7.1.250.0100.00615.65
7.1.240.0050.00715.93
7.1.230.0070.00515.88
7.1.220.0050.00715.75
7.1.210.0070.00415.86
7.1.200.0080.00715.82
7.1.190.0050.00715.85
7.1.180.0030.01015.88
7.1.170.0070.00515.81
7.1.160.0070.00415.77
7.1.150.0080.00515.66
7.1.140.0040.00915.93
7.1.130.0000.01315.65
7.1.120.0050.01115.77
7.1.110.0020.00915.92
7.1.100.0040.00816.49
7.1.90.0060.00915.57
7.1.80.0080.00315.68
7.1.70.0050.00816.29
7.1.60.0040.01117.02
7.1.50.0050.00916.02
7.1.40.0070.00515.73
7.1.30.0060.00615.63
7.1.20.0110.00315.73
7.1.10.0030.00915.80
7.1.00.0010.03217.96
7.0.330.0040.00915.51
7.0.320.0030.00915.26
7.0.310.0100.00315.43
7.0.300.0030.00715.30
7.0.290.0090.00515.45
7.0.280.0050.00615.30
7.0.270.0020.01015.45
7.0.260.0060.00915.41
7.0.250.0040.01115.50
7.0.240.0090.00315.28
7.0.230.0050.00615.44
7.0.220.0030.00715.29
7.0.210.0030.01115.31
7.0.200.0070.00615.64
7.0.190.0050.00615.29
7.0.180.0080.00415.29
7.0.170.0070.00515.33
7.0.160.0100.00515.52
7.0.150.0050.00515.32
7.0.140.0020.03117.75
7.0.130.0050.00715.37
7.0.120.0050.00515.48
7.0.110.0030.00915.29
7.0.100.0040.00615.47
7.0.90.0020.00615.54
7.0.80.0080.00715.48
7.0.70.0020.01215.42
7.0.60.0060.03016.89
7.0.50.0070.02816.32
7.0.40.0070.03015.83
7.0.30.0140.03115.85
7.0.20.0140.03115.71
7.0.10.0160.02915.73
7.0.00.0050.02015.72
5.6.400.0090.00414.23
5.6.390.0010.00914.21
5.6.380.0050.00614.34
5.6.370.0030.01014.30
5.6.360.0080.00714.17
5.6.350.0040.00614.63
5.6.340.0060.00714.50
5.6.330.0050.00714.33
5.6.320.0070.00514.45
5.6.310.0080.00514.19
5.6.300.0020.01214.48
5.6.290.0020.01114.41
5.6.280.0090.02616.57
5.6.270.0070.00714.36
5.6.260.0070.00714.17
5.6.250.0000.01214.22
5.6.240.0070.00414.43
5.6.230.0070.00514.40
5.6.220.0040.00914.59
5.6.210.0050.03216.55
5.6.200.0040.03415.58
5.6.190.0060.03416.26
5.6.180.0070.03216.44
5.6.170.0140.01816.35
5.6.160.0050.01716.29
5.6.150.0060.02815.56
5.6.140.0060.03215.56
5.6.130.0060.01715.63
5.6.120.0060.02516.74
5.6.110.0120.03016.62
5.6.100.0010.02216.59
5.6.90.0100.03016.56
5.6.80.0060.03416.34
5.6.70.0110.02016.33
5.6.60.0050.00814.29
5.6.50.0000.01514.12
5.6.40.0020.01214.16
5.6.30.0060.00614.28
5.6.20.0070.00914.27
5.6.10.0020.01014.14
5.6.00.0070.00814.26
5.5.380.0040.01114.36
5.5.370.0030.00914.43
5.5.360.0020.00914.47
5.5.350.0040.02616.44
5.5.340.0040.02515.57
5.5.330.0040.02016.13
5.5.320.0020.02316.40
5.5.310.0090.03416.33
5.5.300.0090.02015.59
5.5.290.0080.01815.50
5.5.280.0040.02316.52
5.5.270.0090.03216.30
5.5.260.0070.02616.52
5.5.250.0060.03216.35
5.5.240.0040.03216.17
5.5.230.0080.00814.06
5.5.220.0080.00614.26
5.5.210.0050.00814.28
5.5.200.0030.00814.38
5.5.190.0040.01014.34
5.5.180.0070.00914.24
5.5.170.0020.00914.42
5.5.160.0030.01014.31
5.5.150.0030.01014.37
5.5.140.0030.01014.33
5.5.130.0030.01014.17
5.5.120.0080.00514.33
5.5.110.0050.00714.16
5.5.100.0090.00814.07
5.5.90.0080.00614.34
5.5.80.0060.00714.37
5.5.70.0040.01114.10
5.5.60.0070.00614.32
5.5.50.0030.00914.24
5.5.40.0030.00814.35
5.5.30.0040.00914.17
5.5.20.0060.01014.17
5.5.10.0060.00614.17
5.5.00.0040.01114.01
5.4.450.0120.01613.91
5.4.440.0110.01713.94
5.4.430.0090.01913.80
5.4.420.0090.01613.87
5.4.410.0070.01713.91
5.4.400.0080.01913.78
5.4.390.0120.01413.63
5.4.380.0090.01613.60
5.4.370.0100.01613.69
5.4.360.0100.01613.69
5.4.350.0070.01913.78
5.4.340.0060.02013.63
5.4.330.0030.00711.06
5.4.320.0060.01913.77
5.4.310.0140.01813.72
5.4.300.0100.01713.70
5.4.290.0110.02413.63
5.4.280.0150.01913.61
5.4.270.0120.01313.78
5.4.260.0080.01913.53
5.4.250.0080.02113.77
5.4.240.0150.02513.77
5.4.230.0080.03413.64
5.4.220.0130.02313.71
5.4.210.0100.02013.70
5.4.200.0110.02913.68
5.4.190.0110.02813.68
5.4.180.0120.02713.77
5.4.170.0130.01613.71
5.4.160.0090.01713.76
5.4.150.0140.02513.80
5.4.140.0080.02212.88
5.4.130.0060.03312.99
5.4.120.0160.02312.78
5.4.110.0110.02112.79
5.4.100.0110.02612.92
5.4.90.0120.02612.67
5.4.80.0060.01912.97
5.4.70.0130.02512.87
5.4.60.0100.01812.84
5.4.50.0160.02012.79
5.4.40.0110.02812.85
5.4.30.0060.01812.75
5.4.20.0140.02412.69
5.4.10.0100.01612.91
5.4.00.0090.01612.67
5.3.290.0090.01712.17
5.3.280.0140.02512.08
5.3.270.0100.01712.08
5.3.260.0120.01711.96
5.3.250.0120.02912.10
5.3.240.0080.02811.92
5.3.230.0090.01912.04
5.3.220.0100.01712.00
5.3.210.0090.02911.97
5.3.200.0120.02411.90
5.3.190.0090.01911.98
5.3.180.0090.02311.96
5.3.170.0130.01812.03
5.3.160.0170.01711.96
5.3.150.0060.02911.96
5.3.140.0080.01611.95
5.3.130.0100.03112.04
5.3.120.0110.01912.02
5.3.110.0090.02812.05
5.3.100.0060.03011.85
5.3.90.0080.02211.92
5.3.80.0100.01611.75
5.3.70.0110.02311.90
5.3.60.0100.02811.84
5.3.50.0090.02811.86
5.3.40.0070.02011.74
5.3.30.0100.02711.78
5.3.20.0150.02411.73
5.3.10.0090.01811.63
5.3.00.0140.02511.61
5.2.170.0300.05311.08
5.2.160.0270.03011.08
5.2.150.0270.05711.29
5.2.140.0230.03311.09
5.2.130.0230.03011.06
5.2.120.0200.03311.24
5.2.110.0200.05711.35
5.2.100.0270.05311.03
5.2.90.0230.04011.10
5.2.80.0200.03311.20
5.2.70.0370.03011.23
5.2.60.0200.02711.00
5.2.50.0500.05011.02
5.2.40.0200.03310.94
5.2.30.0170.02710.90
5.2.20.0170.03710.88
5.2.10.0200.05310.85
5.2.00.0230.04010.75
5.1.60.0200.02710.10
5.1.50.0470.04010.00
5.1.40.0170.0339.94
5.1.30.0200.04710.36
5.1.20.0130.03310.43
5.1.10.0270.04710.17
5.1.00.0170.05310.08
5.0.50.0100.0408.64
5.0.40.0130.0378.56
5.0.30.0070.0408.47
5.0.20.0070.0438.47
5.0.10.0100.0438.47
5.0.00.0100.0578.47
4.4.90.0300.0378.47
4.4.80.0200.0278.47
4.4.70.0070.0308.47
4.4.60.0130.0308.47
4.4.50.0100.0338.47
4.4.40.0070.0538.47
4.4.30.0070.0378.47
4.4.20.0070.0278.47
4.4.10.0100.0138.47
4.4.00.0130.0178.47
4.3.110.0070.0178.47
4.3.100.0100.0338.47
4.3.90.0070.0178.47
4.3.80.0100.0308.47
4.3.70.0100.0308.47
4.3.60.0070.0178.47
4.3.50.0100.0308.47
4.3.40.0070.0238.47
4.3.30.0000.0338.47
4.3.20.0000.0208.47
4.3.10.0000.0208.47
4.3.00.0030.0138.47

preferences:
46.18 ms | 400 KiB | 5 Q