3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { 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) { 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($values); 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.0140.00718.40
8.3.50.0120.00316.55
8.3.40.0090.00618.84
8.3.30.0030.01218.64
8.3.20.0050.00318.77
8.3.10.0040.00420.68
8.3.00.0050.00519.25
8.2.180.0110.00416.63
8.2.170.0000.01422.96
8.2.160.0100.01022.09
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00019.91
8.2.110.0100.00020.91
8.2.100.0090.00317.84
8.2.90.0030.00719.17
8.2.80.0060.00317.93
8.2.70.0000.00817.63
8.2.60.0080.00017.93
8.2.50.0030.00618.07
8.2.40.0040.00418.16
8.2.30.0030.00518.02
8.2.20.0070.00017.82
8.2.10.0030.00617.75
8.2.00.0040.00417.82
8.1.280.0040.01125.92
8.1.270.0090.00923.99
8.1.260.0070.01126.35
8.1.250.0050.00328.09
8.1.240.0030.00620.57
8.1.230.0040.00820.74
8.1.220.0080.00017.74
8.1.210.0040.00418.97
8.1.200.0090.00017.36
8.1.190.0000.00817.66
8.1.180.0080.00018.10
8.1.170.0000.00918.89
8.1.160.0050.00218.96
8.1.150.0070.00018.67
8.1.140.0040.00417.54
8.1.130.0000.00717.72
8.1.120.0000.00717.38
8.1.110.0000.00817.49
8.1.100.0050.00217.54
8.1.90.0080.00017.48
8.1.80.0000.00717.50
8.1.70.0030.00317.49
8.1.60.0090.00017.59
8.1.50.0050.00317.49
8.1.40.0020.00517.47
8.1.30.0050.00317.69
8.1.20.0030.00517.73
8.1.10.0000.00817.61
8.1.00.0030.00617.51
8.0.300.0070.00019.85
8.0.290.0070.00016.88
8.0.280.0000.00718.40
8.0.270.0030.00317.19
8.0.260.0030.00316.82
8.0.250.0040.00417.09
8.0.240.0030.00717.02
8.0.230.0000.00917.05
8.0.220.0000.00716.85
8.0.210.0040.00416.89
8.0.200.0070.00017.00
8.0.190.0040.00417.05
8.0.180.0000.00717.00
8.0.170.0000.00917.00
8.0.160.0000.00717.07
8.0.150.0000.00916.91
8.0.140.0000.01216.83
8.0.130.0030.00313.36
8.0.120.0030.00516.90
8.0.110.0030.00716.83
8.0.100.0030.00417.08
8.0.90.0040.00416.84
8.0.80.0060.00916.95
8.0.70.0040.00416.87
8.0.60.0000.00716.97
8.0.50.0070.00016.86
8.0.30.0120.00717.04
8.0.20.0070.01317.27
8.0.10.0040.00416.99
8.0.00.0090.01117.00
7.4.330.0050.00014.70
7.4.320.0000.00616.60
7.4.300.0030.00316.66
7.4.290.0000.00716.48
7.4.280.0040.00416.64
7.4.270.0030.00316.61
7.4.260.0040.00413.29
7.4.250.0050.00316.54
7.4.240.0070.00016.60
7.4.230.0070.00016.32
7.4.220.0060.02016.54
7.4.210.0080.00916.60
7.4.200.0030.00316.51
7.4.190.0040.00416.42
7.4.160.0060.01116.47
7.4.150.0100.00717.18
7.4.140.0110.00617.27
7.4.130.0090.00816.47
7.4.120.0110.01016.48
7.4.110.0090.00816.70
7.4.100.0130.00916.50
7.4.90.0140.00316.61
7.4.80.0110.00818.80
7.4.70.0090.01516.65
7.4.60.0060.01016.42
7.4.50.0030.00516.31
7.4.40.0090.00622.27
7.4.30.0090.00616.44
7.4.00.0060.01014.90
7.3.330.0000.00613.24
7.3.320.0060.00013.29
7.3.310.0040.00316.23
7.3.300.0080.00016.25
7.3.290.0170.00316.34
7.3.280.0090.00816.36
7.3.270.0070.01017.18
7.3.260.0050.01218.24
7.3.250.0120.00816.50
7.3.240.0080.00916.61
7.3.230.0130.00316.43
7.3.210.0130.00416.37
7.3.200.0090.01219.39
7.3.190.0120.00616.46
7.3.180.0080.00816.48
7.3.170.0090.00616.40
7.3.160.0180.00016.35
7.3.120.0060.01014.98
7.3.110.0070.01114.95
7.3.100.0100.00414.92
7.3.90.0030.01014.77
7.3.80.0100.00514.94
7.3.70.0020.01114.92
7.3.60.0070.00714.83
7.3.50.0090.00614.81
7.3.40.0050.00814.95
7.3.30.0070.00514.85
7.3.20.0060.00816.60
7.3.10.0070.00516.72
7.3.00.0030.01016.58
7.2.330.0180.00316.52
7.2.320.0030.01916.84
7.2.310.0140.01116.77
7.2.300.0130.01016.85
7.2.290.0120.00916.80
7.2.250.0050.01315.24
7.2.240.0090.01115.12
7.2.230.0090.00414.97
7.2.220.0020.01115.06
7.2.210.0050.00715.13
7.2.200.0070.00515.09
7.2.190.0070.00814.92
7.2.180.0040.01014.94
7.2.170.0070.00714.97
7.2.60.0000.01416.81
7.1.330.0090.00715.82
7.1.320.0020.01315.72
7.1.310.0040.00615.67
7.1.300.0030.00815.63
7.1.290.0040.00715.70
7.1.280.0030.00615.90
7.1.270.0020.00615.66
7.1.260.0080.00315.95
7.1.200.0060.00615.97
7.1.100.0080.00417.72
7.1.70.0040.00417.31
7.1.60.0040.00717.27
7.1.50.0100.01316.96
7.1.00.0030.07722.44
7.0.200.0030.00716.93
7.0.140.0070.07021.92
7.0.60.0170.07719.98
7.0.50.0030.05017.91
7.0.40.0100.04020.23
7.0.30.0470.06720.15
7.0.20.0330.07020.24
7.0.10.0430.07020.33
7.0.00.0070.07720.24
5.6.280.0030.07320.87
5.6.210.0030.06720.53
5.6.200.0170.07718.21
5.6.190.0070.07320.61
5.6.180.0430.07020.65
5.6.170.0330.07320.52
5.6.160.0030.04320.39
5.6.150.0030.08318.27
5.6.140.0100.03718.12
5.6.130.0200.06318.15
5.6.120.0130.06021.15
5.6.110.0070.04021.12
5.6.100.0070.08721.13
5.6.90.0000.04321.00
5.6.80.0030.08020.50
5.5.350.0030.07320.46
5.5.340.0100.03017.95
5.5.330.0070.04020.31
5.5.320.0270.05320.26
5.5.310.0300.07720.26
5.5.300.0070.05018.04
5.5.290.0070.05317.95
5.5.280.0070.08720.89
5.5.270.0030.09020.99
5.5.260.0100.08020.78
5.5.250.0030.05020.48
5.5.240.0100.08020.18
5.4.450.0130.05319.43
5.4.440.0000.04319.61
5.4.430.0030.05019.18
5.4.420.0130.03719.32
5.4.410.0030.05019.20
5.4.400.0030.04019.21
5.4.390.0030.04019.16
5.4.380.0100.06019.15
5.4.370.0070.07319.08
5.4.360.0070.06319.14
5.4.350.0070.04019.15
5.4.340.0100.04719.01
5.4.320.0070.04019.14
5.4.310.0030.04319.00
5.4.300.0070.05319.15
5.4.290.0070.04319.20
5.4.280.0200.06018.99
5.4.270.0030.05719.12
5.4.260.0130.06719.20
5.4.250.0070.06319.20
5.4.240.0070.04319.00
5.4.230.0070.05019.00
5.4.220.0030.05718.91
5.4.210.0030.06718.96
5.4.200.0070.06319.23
5.4.190.0030.06318.84
5.4.180.0030.08318.88
5.4.170.0100.07019.08
5.4.160.0070.03319.23
5.4.150.0130.03018.85
5.4.140.0100.07016.43
5.4.130.0100.03316.26
5.4.120.0100.05016.38
5.4.110.0070.04716.34
5.4.100.0030.07716.30
5.4.90.0130.03716.38
5.4.80.0000.04716.28
5.4.70.0070.07016.50
5.4.60.0030.05716.46
5.4.50.0070.07716.35
5.4.40.0070.05716.27
5.4.30.0000.04016.46
5.4.20.0070.05716.46
5.4.10.0070.03316.36
5.4.00.0000.04715.84
5.3.290.0100.03314.68
5.3.280.0170.07014.79
5.3.270.0030.05014.67
5.3.260.0000.06014.51
5.3.250.0070.04014.55
5.3.240.0000.08714.55
5.3.230.0070.04314.54
5.3.220.0070.07014.60
5.3.210.0030.06314.63
5.3.200.0070.04314.59
5.3.190.0030.08014.63
5.3.180.0000.04314.50
5.3.170.0000.08014.66
5.3.160.0030.04314.50
5.3.150.0000.04314.64
5.3.140.0000.04014.57
5.3.130.0070.03714.57
5.3.120.0000.04314.63
5.3.110.0030.04714.57
5.3.100.0130.05714.10
5.3.90.0000.04314.19
5.3.80.0030.05014.00
5.3.70.0030.04014.03
5.3.60.0070.03313.99
5.3.50.0030.03713.91
5.3.40.0130.05313.93
5.3.30.0070.04313.93
5.3.20.0030.04013.87
5.3.10.0070.03313.63
5.3.00.0000.05013.66
5.2.170.0030.03011.17
5.2.160.0030.03711.07
5.2.150.0030.03711.24
5.2.140.0030.03711.13
5.2.130.0030.03011.13
5.2.120.0070.03711.14
5.2.110.0170.04311.20
5.2.100.0030.03311.16
5.2.90.0030.06311.17
5.2.80.0070.04011.11
5.2.70.0000.05011.07
5.2.60.0100.06011.11
5.2.50.0030.06311.12
5.2.40.0070.05711.18
5.2.30.0000.03310.91
5.2.20.0030.06311.04
5.2.10.0000.03710.89
5.2.00.0000.03010.75
5.1.60.0030.03310.07
5.1.50.0070.0379.99
5.1.40.0030.04310.16
5.1.30.0030.04310.42
5.1.20.0100.05010.53
5.1.10.0100.04710.06
5.1.00.0030.02710.07
5.0.50.0000.0478.51
5.0.40.0030.0478.42
5.0.30.0000.0678.33
5.0.20.0000.0378.29
5.0.10.0070.0408.11
5.0.00.0000.0438.27
4.4.90.0000.0377.74
4.4.80.0030.0237.74
4.4.70.0000.0407.74
4.4.60.0000.0377.74
4.4.50.0030.0377.74
4.4.40.0000.0477.74
4.4.30.0070.0337.74
4.4.20.0070.0277.74
4.4.10.0030.0137.74
4.4.00.0030.0277.74
4.3.110.0030.0177.74
4.3.100.0030.0337.74
4.3.90.0030.0177.74
4.3.80.0030.0337.74
4.3.70.0000.0407.74
4.3.60.0070.0307.74
4.3.50.0000.0277.74
4.3.40.0030.0307.74
4.3.30.0030.0337.74
4.3.20.0000.0277.74
4.3.10.0030.0377.74
4.3.00.0030.0277.74

preferences:
47.22 ms | 401 KiB | 5 Q