3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); /* public function __construct($array) { 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 $var = array(); 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->items[$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.0110.00416.75
8.3.50.0260.00422.11
8.3.40.0120.00918.99
8.3.30.0090.00619.09
8.3.20.0080.00020.16
8.3.10.0080.00023.68
8.3.00.0040.00419.38
8.2.180.0170.00318.45
8.2.170.0100.00722.96
8.2.160.0100.00320.39
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0110.00326.16
8.2.120.0070.00022.19
8.2.110.0040.00420.99
8.2.100.0060.00617.78
8.2.90.0040.00419.17
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0030.00518.03
8.2.50.0050.00318.10
8.2.40.0050.00318.16
8.2.30.0080.00318.00
8.2.20.0000.00817.56
8.2.10.0000.00718.25
8.2.00.0090.00017.88
8.1.280.0170.00325.92
8.1.270.0050.00322.19
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0090.00022.19
8.1.230.0110.00017.83
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0040.00417.35
8.1.180.0050.00318.10
8.1.170.0050.00518.64
8.1.160.0070.00022.03
8.1.150.0000.00718.53
8.1.140.0000.00717.47
8.1.130.0000.00717.81
8.1.120.0070.00017.38
8.1.110.0040.00417.47
8.1.100.0000.00717.46
8.1.90.0040.00417.43
8.1.80.0000.00717.48
8.1.70.0000.00717.35
8.1.60.0040.00417.64
8.1.50.0030.00517.58
8.1.40.0030.00617.59
8.1.30.0030.00517.51
8.1.20.0030.00617.64
8.1.10.0000.00817.42
8.1.00.0000.00817.58
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0000.00718.38
8.0.270.0000.00817.29
8.0.260.0040.00416.84
8.0.250.0040.00416.99
8.0.240.0030.00316.81
8.0.230.0000.00816.95
8.0.220.0000.00716.80
8.0.210.0030.00316.91
8.0.200.0030.00316.86
8.0.190.0030.00616.95
8.0.180.0050.00316.96
8.0.170.0070.00016.95
8.0.160.0040.00416.86
8.0.150.0050.00316.89
8.0.140.0080.00016.82
8.0.130.0000.00613.40
8.0.120.0040.00416.80
8.0.110.0030.00516.88
8.0.100.0050.00316.74
8.0.90.0080.00016.78
8.0.80.0070.01416.83
8.0.70.0050.00316.80
8.0.60.0050.00216.73
8.0.50.0070.00016.89
8.0.30.0080.01117.07
8.0.20.0090.01017.40
8.0.10.0040.00417.09
8.0.00.0120.00716.71
7.4.330.0020.00215.07
7.4.320.0030.00316.45
7.4.300.0040.00416.58
7.4.290.0040.00416.53
7.4.280.0050.00316.57
7.4.270.0030.00316.63
7.4.260.0030.00316.60
7.4.250.0040.00416.48
7.4.240.0020.00616.61
7.4.230.0000.00716.72
7.4.220.0070.01016.52
7.4.210.0070.00816.66
7.4.200.0000.00716.55
7.4.190.0030.00516.43
7.4.160.0120.00416.75
7.4.150.0140.00317.40
7.4.140.0140.00417.86
7.4.130.0080.00916.55
7.4.120.0080.01216.48
7.4.110.0100.01016.46
7.4.100.0170.00016.45
7.4.90.0110.00616.55
7.4.80.0040.01319.39
7.4.70.0060.01116.68
7.4.60.0060.01116.58
7.4.50.0040.00416.54
7.4.40.0000.01822.77
7.4.30.0060.01216.62
7.4.00.0060.01114.89
7.3.330.0060.00013.26
7.3.320.0050.00013.27
7.3.310.0070.00016.41
7.3.300.0070.00016.19
7.3.290.0090.00616.30
7.3.280.0030.01616.29
7.3.270.0070.01017.40
7.3.260.0070.01716.58
7.3.250.0110.00716.32
7.3.240.0070.01416.48
7.3.230.0130.00316.39
7.3.210.0140.00816.29
7.3.200.0070.01119.39
7.3.190.0070.01116.50
7.3.180.0110.00816.62
7.3.170.0070.00716.35
7.3.160.0110.00616.61
7.3.120.0070.00714.56
7.3.110.0080.00814.63
7.3.100.0100.01014.53
7.3.90.0090.00514.61
7.3.80.0100.01014.74
7.3.70.0090.00014.56
7.3.60.0040.00714.86
7.3.50.0030.01314.39
7.3.40.0060.00614.51
7.3.30.0080.00614.96
7.3.20.0070.01116.43
7.3.10.0060.00616.45
7.3.00.0040.01016.63
7.2.330.0070.01016.48
7.2.320.0090.00916.78
7.2.310.0030.01416.71
7.2.300.0100.00616.50
7.2.290.0100.00716.82
7.2.250.0110.00714.92
7.2.240.0060.01314.75
7.2.230.0040.01214.91
7.2.220.0060.00915.06
7.2.210.0060.01314.73
7.2.200.0000.01314.77
7.2.190.0070.00315.01
7.2.180.0070.01015.19
7.2.170.0030.01215.12
7.2.160.0070.00715.00
7.2.150.0040.01116.75
7.2.140.0060.00916.82
7.2.130.0060.00816.89
7.2.120.0000.01316.95
7.2.110.0090.00516.89
7.2.100.0030.00916.98
7.2.90.0090.00616.81
7.2.80.0110.00516.90
7.2.70.0030.01016.93
7.2.60.0040.00816.77
7.2.50.0040.00916.91
7.2.40.0050.00916.79
7.2.30.0040.00716.78
7.2.20.0080.00816.81
7.2.10.0070.00716.94
7.2.00.0090.00517.80
7.1.330.0070.01015.86
7.1.320.0030.01315.52
7.1.310.0040.00815.55
7.1.300.0050.00515.46
7.1.290.0030.00915.55
7.1.280.0070.00715.84
7.1.270.0070.00615.63
7.1.260.0110.00315.73
7.1.250.0060.00515.53
7.1.240.0100.00715.61
7.1.230.0030.00915.72
7.1.220.0000.00915.74
7.1.210.0090.00615.78
7.1.200.0100.00915.70
7.1.190.0070.00315.80
7.1.180.0050.00415.61
7.1.170.0090.00015.63
7.1.160.0030.01315.80
7.1.150.0030.00615.59
7.1.140.0000.00915.30
7.1.130.0080.00815.86
7.1.120.0060.00615.64
7.1.110.0070.00715.94
7.1.100.0040.00717.02
7.1.90.0090.00615.64
7.1.80.0000.01115.65
7.1.70.0000.01216.41
7.1.60.0060.01017.41
7.1.50.0070.01216.37
7.1.40.0140.00015.64
7.1.30.0030.00615.73
7.1.20.0030.00615.73
7.1.10.0070.00715.63
7.1.00.0030.04319.18
7.0.330.0050.00815.11
7.0.320.0030.01015.00
7.0.310.0070.00715.30
7.0.300.0120.00015.27
7.0.290.0060.00615.17
7.0.280.0040.01115.34
7.0.270.0030.01015.29
7.0.260.0040.00415.39
7.0.250.0070.00715.50
7.0.240.0000.01215.44
7.0.230.0090.00615.25
7.0.220.0000.01515.23
7.0.210.0030.01015.41
7.0.200.0050.00616.07
7.0.190.0070.00715.42
7.0.180.0030.00915.30
7.0.170.0040.00415.30
7.0.160.0030.00715.53
7.0.150.0070.00315.51
7.0.140.0050.03818.73
7.0.130.0040.01115.25
7.0.120.0090.00615.21
7.0.110.0060.00615.20
7.0.100.0030.00614.99
7.0.90.0040.01215.42
7.0.80.0040.01115.25
7.0.70.0040.01115.43
7.0.60.0040.02517.66
7.0.50.0080.03816.58
7.0.40.0040.04516.67
7.0.30.0130.02316.77
7.0.20.0240.04016.72
7.0.10.0080.04516.82
7.0.00.0050.02416.63
5.6.400.0080.00514.59
5.6.390.0060.00614.04
5.6.380.0030.00714.57
5.6.370.0080.00414.44
5.6.360.0060.00914.28
5.6.350.0110.00314.34
5.6.340.0030.01014.26
5.6.330.0070.00714.45
5.6.320.0060.00314.41
5.6.310.0040.01114.27
5.6.300.0030.01014.34
5.6.290.0100.00314.74
5.6.280.0100.03717.50
5.6.270.0130.00714.07
5.6.260.0070.00714.43
5.6.250.0030.01014.33
5.6.240.0030.01014.37
5.6.230.0090.00914.26
5.6.220.0030.00714.25
5.6.210.0070.04317.45
5.6.200.0090.03016.16
5.6.190.0050.04317.37
5.6.180.0200.02317.52
5.6.170.0160.01817.53
5.6.160.0070.03417.44
5.6.150.0030.04216.21
5.6.140.0050.04416.10
5.6.130.0030.04616.17
5.6.120.0050.02417.61
5.6.110.0080.02217.63
5.6.100.0050.02817.53
5.6.90.0070.04717.73
5.6.80.0070.03817.28
5.6.70.0060.00314.13
5.6.60.0090.00614.29
5.6.50.0030.00714.09
5.6.40.0110.00414.41
5.6.30.0030.00714.54
5.6.20.0120.00414.01
5.6.10.0030.00914.51
5.6.00.0040.01114.33
5.5.380.0070.00714.55
5.5.370.0060.01314.34
5.5.360.0100.00714.36
5.5.350.0200.04017.46
5.5.340.0050.04016.23
5.5.330.0020.02517.46
5.5.320.0070.04317.23
5.5.310.0200.04017.56
5.5.300.0100.02016.01
5.5.290.0020.04716.19
5.5.280.0100.04017.63
5.5.270.0080.03817.39
5.5.260.0080.04317.43
5.5.250.0050.02317.61
5.5.240.0040.03417.22
5.5.230.0140.00014.15
5.5.220.0060.00914.45
5.5.210.0130.00314.29
5.5.200.0040.01114.21
5.5.190.0030.00614.29
5.5.180.0040.01414.12
5.5.170.0030.01314.32
5.5.160.0030.01014.11
5.5.150.0080.00814.55
5.5.140.0080.00814.36
5.5.130.0120.00314.59
5.5.120.0060.00814.22
5.5.110.0070.00714.46
5.5.100.0030.01314.10
5.5.90.0060.00614.34
5.5.80.0060.01414.54
5.5.70.0030.01514.55
5.5.60.0100.00714.04
5.5.50.0060.01014.43
5.5.40.0080.00613.88
5.5.30.0030.00714.36
5.5.20.0120.00314.30
5.5.10.0090.00614.00
5.5.00.0070.00714.16
5.4.450.0250.03515.39
5.4.440.0490.02815.45
5.4.430.0100.04315.41
5.4.420.0470.03115.00
5.4.410.0480.04114.96
5.4.400.0500.03014.82
5.4.390.0460.02515.13
5.4.380.0600.04514.77
5.4.370.0220.03114.81
5.4.360.0230.02614.80
5.4.350.0180.02914.78
5.4.340.0270.03014.86
5.4.330.0070.00711.06
5.4.320.0030.02811.88
5.4.310.0060.02111.93
5.4.300.0030.02111.80
5.4.290.0080.01711.83
5.4.280.0060.02011.82
5.4.270.0110.01911.89
5.4.260.0060.02511.84
5.4.250.0060.02311.72
5.4.240.0040.02111.70
5.4.230.0100.02311.79
5.4.220.0080.01911.60
5.4.210.0070.02311.61
5.4.200.0040.02311.67
5.4.190.0110.02511.60
5.4.180.0100.02311.72
5.4.170.0070.02611.74
5.4.160.0110.02411.76
5.4.150.0110.02611.84
5.4.140.0100.02411.56
5.4.130.0070.02611.64
5.4.120.0080.02811.64
5.4.110.0070.02711.49
5.4.100.0080.02511.41
5.4.90.0160.03211.41
5.4.80.0090.02511.61
5.4.70.0190.04511.55
5.4.60.0110.02411.55
5.4.50.0090.02511.62
5.4.40.0090.02311.58
5.4.30.0110.02411.61
5.4.20.0130.02011.63
5.4.10.0100.02311.56
5.4.00.0140.05011.32
5.3.290.0050.02111.80
5.3.280.0080.02411.75
5.3.270.0080.02811.76
5.3.260.0100.02611.76
5.3.250.0120.02511.76
5.3.240.0090.02511.76
5.3.230.0110.02311.75
5.3.220.0110.02511.74
5.3.210.0180.03211.74
5.3.200.0090.02411.73
5.3.190.0100.02411.73
5.3.180.0070.02711.73
5.3.170.0120.02211.73
5.3.160.0080.02711.73
5.3.150.0120.02311.73
5.3.140.0060.02711.73
5.3.130.0130.02311.72
5.3.120.0150.03311.72
5.3.110.0090.02611.72
5.3.100.0100.02511.46
5.3.90.0090.02711.46
5.3.80.0180.03411.45
5.3.70.0110.02311.45
5.3.60.0100.02311.45
5.3.50.0080.02511.42
5.3.40.0100.02311.42
5.3.30.0100.02211.40
5.3.20.0140.03411.29
5.3.10.0060.02911.27
5.3.00.0090.02211.26
5.2.170.0210.0569.24
5.2.160.0110.0359.24
5.2.150.0100.0379.23
5.2.140.0130.0339.23
5.2.130.0170.0599.20
5.2.120.0170.0299.20
5.2.110.0070.0409.20
5.2.100.0100.0359.20
5.2.90.0110.0359.20
5.2.80.0140.0339.20
5.2.70.0100.0379.20
5.2.60.0160.0309.14
5.2.50.0110.0369.11
5.2.40.0160.0329.09
5.2.30.0090.0379.07
5.2.20.0240.0549.07
5.2.10.0130.0358.96
5.2.00.0130.0328.82
5.1.60.0120.0298.11
5.1.50.0130.0288.10
5.1.40.0120.0298.09
5.1.30.0140.0298.44
5.1.20.0140.0298.46
5.1.10.0090.0348.19
5.1.00.0070.0348.18
5.0.50.0100.0246.67
5.0.40.0100.0216.52
5.0.30.0100.0336.34
5.0.20.0100.0216.30
5.0.10.0080.0236.29
5.0.00.0090.0356.28
4.4.90.0080.0164.78
4.4.80.0070.0184.75
4.4.70.0040.0214.76
4.4.60.0080.0174.76
4.4.50.0110.0134.77
4.4.40.0070.0284.71
4.4.30.0060.0194.76
4.4.20.0070.0174.84
4.4.10.0050.0204.85
4.4.00.0090.0264.76
4.3.110.0070.0174.67
4.3.100.0160.0384.66
4.3.90.0080.0164.63
4.3.80.0090.0254.58
4.3.70.0060.0174.63
4.3.60.0070.0174.63
4.3.50.0060.0184.63
4.3.40.0060.0274.53
4.3.30.0030.0203.29
4.3.20.0050.0183.29
4.3.10.0060.0163.25
4.3.00.0030.0277.55

preferences:
46.29 ms | 401 KiB | 5 Q