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');*/ $value = $value; $coll = new MyIterator($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.0090.00618.68
8.3.50.0050.01217.38
8.3.40.0190.00318.53
8.3.30.0110.00318.78
8.3.20.0050.00318.60
8.3.10.0000.00918.71
8.3.00.0040.00419.25
8.2.180.0150.00425.92
8.2.170.0150.00019.09
8.2.160.0030.01022.96
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0000.00720.73
8.2.110.0060.00322.27
8.2.100.0090.00319.63
8.2.90.0030.00617.75
8.2.80.0040.00418.73
8.2.70.0040.00417.63
8.2.60.0050.00317.80
8.2.50.0040.00417.93
8.2.40.0080.00020.07
8.2.30.0030.00617.79
8.2.20.0060.00317.70
8.2.10.0040.00417.71
8.2.00.0050.00317.72
8.1.280.0100.00725.92
8.1.270.0040.00423.99
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0000.00920.73
8.1.230.0040.00817.66
8.1.220.0040.00417.79
8.1.210.0080.00018.77
8.1.200.0080.00017.48
8.1.190.0030.00617.22
8.1.180.0000.00818.10
8.1.170.0000.00817.62
8.1.160.0000.00719.09
8.1.150.0040.00418.55
8.1.140.0040.00417.41
8.1.130.0000.00717.94
8.1.120.0000.00717.52
8.1.110.0040.00417.48
8.1.100.0070.00417.48
8.1.90.0040.00417.47
8.1.80.0080.00017.40
8.1.70.0000.00817.51
8.1.60.0050.00317.49
8.1.50.0030.00517.43
8.1.40.0030.00617.61
8.1.30.0060.00317.57
8.1.20.0040.00717.75
8.1.10.0000.00717.58
8.1.00.0080.00017.57
8.0.300.0040.00418.77
8.0.290.0020.00516.63
8.0.280.0070.00018.46
8.0.270.0070.00017.30
8.0.260.0000.00718.55
8.0.250.0040.00416.93
8.0.240.0000.00717.02
8.0.230.0030.00516.99
8.0.220.0030.00316.94
8.0.210.0070.00016.99
8.0.200.0060.00017.04
8.0.190.0030.00617.06
8.0.180.0040.00417.00
8.0.170.0040.00416.91
8.0.160.0070.00017.03
8.0.150.0060.00316.83
8.0.140.0060.00316.92
8.0.130.0030.00313.46
8.0.120.0030.00616.80
8.0.110.0000.00716.86
8.0.100.0070.00016.96
8.0.90.0000.00717.05
8.0.80.0040.01117.00
8.0.70.0000.00716.95
8.0.60.0000.00816.99
8.0.50.0030.00516.86
8.0.30.0030.01317.23
8.0.20.0100.00817.07
8.0.10.0000.00717.13
8.0.00.0150.01016.75
7.4.330.0030.00313.04
7.4.320.0040.00416.54
7.4.300.0030.00316.55
7.4.290.0030.00316.54
7.4.280.0030.00516.55
7.4.270.0030.00316.47
7.4.260.0000.00613.32
7.4.250.0040.00416.52
7.4.240.0030.00316.47
7.4.230.0070.00016.38
7.4.220.0100.00716.54
7.4.210.0120.00916.59
7.4.200.0030.00316.43
7.4.190.0070.00016.71
7.4.160.0130.00316.46
7.4.150.0110.00816.55
7.4.140.0130.00416.54
7.4.130.0090.00916.53
7.4.120.0100.01316.56
7.4.110.0090.00916.55
7.4.100.0090.00816.49
7.4.90.0090.00916.59
7.4.80.0060.01619.39
7.4.70.0130.00716.71
7.4.60.0060.01116.61
7.4.50.0000.00916.29
7.4.40.0040.01416.55
7.4.30.0070.01016.48
7.4.00.0080.00714.98
7.3.330.0000.00613.37
7.3.320.0000.00713.29
7.3.310.0030.00316.42
7.3.300.0000.00616.48
7.3.290.0070.01016.47
7.3.280.0140.00416.42
7.3.270.0140.00316.34
7.3.260.0040.01216.69
7.3.250.0120.01016.55
7.3.240.0110.00716.44
7.3.230.0050.01116.52
7.3.210.0060.00916.60
7.3.200.0120.00916.49
7.3.190.0030.01416.50
7.3.180.0160.00316.40
7.3.170.0030.01316.50
7.3.160.0100.00716.65
7.3.120.0060.00914.99
7.2.330.0120.00616.95
7.2.320.0000.01716.45
7.2.310.0090.01516.85
7.2.300.0060.01116.83
7.2.290.0060.01016.66
7.2.00.0000.01419.38
7.1.100.0060.00618.18
7.1.70.0030.00317.25
7.1.60.0120.00919.30
7.1.50.0140.00716.90
7.1.00.0070.07022.25
7.0.200.0040.00416.61
7.0.140.0030.07322.15
7.0.120.0030.03321.96
7.0.60.0070.07019.89
7.0.50.0070.07717.89
7.0.40.0070.04720.13
7.0.30.0130.04720.33
7.0.20.0200.05320.09
7.0.10.0230.04020.09
7.0.00.0030.09020.05
5.6.280.0000.07721.00
5.6.210.0070.07320.54
5.6.200.0070.08718.16
5.6.190.0170.06020.63
5.6.180.0230.04720.39
5.6.170.0330.08020.54
5.6.160.0130.04320.57
5.6.150.0070.06718.21
5.6.140.0030.05318.18
5.6.130.0000.08318.14
5.6.120.0030.04721.13
5.6.110.0170.04321.05
5.6.100.0000.05021.02
5.6.90.0100.04720.98
5.6.80.0130.07720.45
5.6.70.0170.03320.39
5.5.350.0400.06320.45
5.5.340.0000.05317.99
5.5.330.0070.04020.44
5.5.320.0100.07320.42
5.5.310.0230.07720.36
5.5.300.0070.04017.95
5.5.290.0100.05317.95
5.5.280.0170.06720.87
5.5.270.0070.08020.98
5.5.260.0170.07720.66
5.5.250.0100.07320.51
5.5.240.0070.06720.28
5.4.450.0070.05019.57
5.4.440.0070.08019.27
5.4.430.0130.07719.45
5.4.420.0030.05019.52
5.4.410.0030.08319.09
5.4.400.0070.07718.86
5.4.390.0000.05719.25
5.4.380.0100.05719.15
5.4.370.0030.05718.85
5.4.360.0030.06319.02
5.4.350.0030.05019.11
5.4.340.0130.04019.24
5.4.320.0100.03319.25
5.4.310.0000.06019.20
5.4.300.0070.04319.25
5.4.290.0030.07319.13
5.4.280.0100.03719.14
5.4.270.0070.05719.11
5.4.260.0100.07019.16
5.4.250.0030.08719.14
5.4.240.0100.05019.14
5.4.230.0030.04719.14
5.4.220.0170.06718.84
5.4.210.0100.06318.98
5.4.200.0100.04019.20
5.4.190.0070.05019.13
5.4.180.0070.03719.09
5.4.170.0030.08018.86
5.4.160.0100.05019.13
5.4.150.0100.07319.13
5.4.140.0030.07716.29
5.4.130.0130.06716.41
5.4.120.0070.07016.37
5.4.110.0000.06016.42
5.4.100.0100.05716.30
5.4.90.0030.04716.43
5.4.80.0100.06316.38
5.4.70.0100.06316.48
5.4.60.0070.03716.39
5.4.50.0070.04016.44
5.4.40.0070.04016.38
5.4.30.0070.06716.34
5.4.20.0030.07316.27
5.4.10.0000.05316.40
5.4.00.0030.04015.83
5.3.290.0070.05314.70
5.3.280.0070.08014.62
5.3.270.0070.06714.66
5.3.260.0100.07314.66
5.3.250.0100.07314.66
5.3.240.0100.07714.62
5.3.230.0030.06714.68
5.3.220.0030.08014.58
5.3.210.0030.08714.73
5.3.200.0130.06714.58
5.3.190.0100.07714.73
5.3.180.0000.08714.60
5.3.170.0000.06014.63
5.3.160.0130.04714.74
5.3.150.0100.07014.59
5.3.140.0070.04714.59
5.3.130.0100.07314.53
5.3.120.0100.06714.57
5.3.110.0100.07714.57
5.3.100.0130.05714.06
5.3.90.0230.07014.11
5.3.80.0070.07314.10
5.3.70.0070.07314.01
5.3.60.0200.05714.07
5.3.50.0030.07313.96
5.3.40.0070.07714.00
5.3.30.0130.06714.09
5.3.20.0070.06013.72
5.3.10.0070.06713.82
5.3.00.0000.06713.66
5.2.170.0030.06711.18
5.2.160.0030.06011.33
5.2.150.0030.03711.07
5.2.140.0100.05711.14
5.2.130.0000.06011.28
5.2.120.0030.06711.28
5.2.110.0070.05711.09
5.2.100.0070.06311.02
5.2.90.0070.04311.08
5.2.80.0100.04011.08
5.2.70.0030.06311.13
5.2.60.0130.06011.09
5.2.50.0070.05711.09
5.2.40.0030.04711.06
5.2.30.0100.03711.14
5.2.20.0070.06011.05
5.2.10.0000.04010.94
5.2.00.0100.04310.75
5.1.60.0030.05710.02
5.1.50.0030.06010.09
5.1.40.0030.05010.00
5.1.30.0170.05010.36
5.1.20.0030.05010.43
5.1.10.0100.04010.16
5.1.00.0070.03710.11
5.0.50.0000.0538.70
5.0.40.0000.0308.70
5.0.30.0000.0708.70
5.0.20.0030.0308.70
5.0.10.0070.0238.70
5.0.00.0000.0608.70
4.4.90.0000.0378.70
4.4.80.0070.0238.70
4.4.70.0000.0308.70
4.4.60.0030.0138.70
4.4.50.0000.0178.70
4.4.40.0030.0538.70
4.4.30.0030.0378.70
4.4.20.0030.0378.70
4.4.10.0000.0408.70
4.4.00.0000.0408.70
4.3.110.0030.0178.70
4.3.100.0070.0278.70
4.3.90.0030.0238.70
4.3.80.0000.0478.70
4.3.70.0000.0278.70
4.3.60.0000.0208.70
4.3.50.0030.0308.70
4.3.40.0000.0438.70
4.3.30.0070.0308.70
4.3.20.0000.0378.70
4.3.10.0030.0378.70
4.3.00.0070.0138.70

preferences:
47.34 ms | 401 KiB | 5 Q