3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(1,2,3); private $current; private $key; public function __construct($array = null) { if (is_array($array)) { $this->var = $array; } } public function __set($name, $value) { return $this->var[$name] = $value; } public function __get($name) { if (isset($this->var[$name])) { return $this->var[$name]; } if ($name == 'test') { $this->$name = $this->$name(); } } public function many() { $a = array(88,99,11); return $a[$this->key]; } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); $this->current = $var; echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); $this->key = $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 foo extends MyIterator{ public function test(){ return $this->many(); } } $it = new foo(); foreach ($it as $a => $b) { echo PHP_EOL . $it->test() . PHP_EOL . PHP_EOL; print "$a: $b\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.0060.00916.75
8.3.50.0140.00716.38
8.3.40.0110.00418.83
8.3.30.0110.00418.80
8.3.20.0070.00020.39
8.3.10.0040.00423.51
8.3.00.0040.00421.96
8.2.180.0090.01216.88
8.2.170.0110.00422.96
8.2.160.0070.00719.21
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00719.30
8.2.120.0090.00626.35
8.2.110.0000.01020.43
8.2.100.0000.01217.57
8.2.90.0000.00819.31
8.2.80.0030.00517.97
8.2.70.0030.00517.49
8.2.60.0060.00318.05
8.2.50.0000.00818.10
8.2.40.0030.00520.47
8.2.30.0080.00019.41
8.2.20.0050.00218.07
8.2.10.0040.00418.27
8.2.00.0040.00418.03
8.1.280.0160.00325.92
8.1.270.0000.00822.01
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00022.20
8.1.230.0000.01119.15
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0090.00017.35
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0040.00418.46
8.1.160.0040.00419.05
8.1.150.0040.00420.68
8.1.140.0000.00719.61
8.1.130.0000.00818.98
8.1.120.0040.00417.51
8.1.110.0050.00317.42
8.1.100.0000.00917.48
8.1.90.0040.00417.40
8.1.80.0000.00717.46
8.1.70.0070.00017.48
8.1.60.0040.00417.65
8.1.50.0020.00517.59
8.1.40.0000.00817.42
8.1.30.0030.00517.68
8.1.20.0000.00817.55
8.1.10.0000.00917.59
8.1.00.0000.00817.54
8.0.300.0040.00418.77
8.0.290.0080.00016.63
8.0.280.0000.00718.48
8.0.270.0070.00017.20
8.0.260.0050.00216.90
8.0.250.0000.00917.00
8.0.240.0030.00517.04
8.0.230.0090.00016.86
8.0.220.0070.00016.89
8.0.210.0000.00716.83
8.0.200.0000.00717.00
8.0.190.0040.00416.95
8.0.180.0000.00716.86
8.0.170.0070.00016.82
8.0.160.0040.00416.97
8.0.150.0070.00016.98
8.0.140.0070.00016.87
8.0.130.0060.00013.38
8.0.120.0050.00316.87
8.0.110.0000.00816.91
8.0.100.0030.00616.84
8.0.90.0050.00316.95
8.0.80.0110.00716.97
8.0.70.0000.00816.79
8.0.60.0040.00416.82
8.0.50.0040.00416.88
8.0.30.0100.00716.99
8.0.20.0110.00817.41
8.0.10.0080.00016.87
8.0.00.0090.00916.70
7.4.330.0060.00015.55
7.4.320.0000.00616.46
7.4.300.0070.00016.57
7.4.290.0030.00316.68
7.4.280.0030.00616.54
7.4.270.0070.00016.40
7.4.260.0040.00416.57
7.4.250.0040.00416.61
7.4.240.0040.00416.54
7.4.230.0070.00016.70
7.4.220.0130.00416.68
7.4.210.0100.00616.59
7.4.200.0070.00016.70
7.4.160.0060.01216.61
7.4.150.0060.01217.40
7.4.140.0080.01217.86
7.4.130.0190.00616.54
7.4.120.0120.00616.45
7.4.110.0110.00516.59
7.4.100.0120.00916.53
7.4.90.0080.00816.56
7.4.80.0140.00319.39
7.4.70.0070.01016.49
7.4.60.0130.00316.48
7.4.50.0120.00316.37
7.4.40.0170.00016.59
7.4.30.0120.00416.45
7.4.00.0060.00915.10
7.3.330.0040.00413.23
7.3.320.0050.00013.34
7.3.310.0000.00716.40
7.3.300.0070.00016.33
7.3.290.0110.00916.38
7.3.280.0090.00716.35
7.3.270.0070.01017.40
7.3.260.0060.01116.57
7.3.250.0120.00916.50
7.3.240.0140.00516.34
7.3.230.0090.00916.35
7.3.210.0070.01016.39
7.3.200.0060.01216.25
7.3.190.0060.00916.55
7.3.180.0060.01216.52
7.3.170.0070.01016.44
7.3.160.0030.01216.30
7.3.120.0090.00614.55
7.3.110.0030.01014.93
7.3.100.0070.00714.88
7.3.90.0000.01714.85
7.3.80.0140.00014.70
7.3.70.0030.01214.76
7.3.60.0000.01414.94
7.3.50.0100.00314.54
7.3.40.0000.00914.76
7.3.30.0110.00414.89
7.3.20.0050.00516.63
7.3.10.0040.01116.83
7.3.00.0030.00616.70
7.2.330.0120.00616.84
7.2.320.0120.01016.70
7.2.310.0100.00716.70
7.2.300.0120.00916.78
7.2.290.0150.00316.78
7.2.240.0030.00915.14
7.2.230.0030.01314.98
7.2.220.0100.00314.99
7.2.210.0000.01415.16
7.2.200.0070.00714.96
7.2.190.0060.00914.87
7.2.180.0090.00615.05
7.2.170.0000.01314.84
7.2.160.0000.01515.09
7.2.150.0110.00416.88
7.2.140.0030.00916.95
7.2.130.0060.01216.96
7.2.120.0070.01016.68
7.2.110.0000.01116.76
7.2.100.0110.00416.79
7.2.90.0020.01316.70
7.2.80.1240.00316.84
7.2.70.0030.01016.89
7.2.60.0040.00916.95
7.2.50.0080.00316.78
7.2.40.0680.00815.99
7.2.30.0000.01516.97
7.2.20.0110.00416.96
7.2.10.0020.01316.89
7.2.00.0080.00817.06
7.1.330.0030.00615.50
7.1.320.0040.01115.56
7.1.310.0090.00615.55
7.1.300.0030.01215.55
7.1.290.0100.00315.85
7.1.280.0070.00315.91
7.1.270.0070.00715.55
7.1.260.0140.00015.74
7.1.250.0040.01115.72
7.1.210.0030.01015.77
7.1.200.0100.00515.96
7.1.190.0120.00315.82
7.1.180.0000.01115.80
7.1.170.0090.00315.80
7.1.160.0960.00915.70
7.1.150.0040.00815.96
7.1.140.0030.01015.95
7.1.130.1850.00616.01
7.1.120.0120.00015.61
7.1.110.0090.00615.59
7.1.100.0030.01215.76
7.1.90.0110.00615.70
7.1.80.0060.01015.82
7.1.70.0030.01315.54
7.1.60.0280.01533.96
7.1.50.0190.01333.75
7.1.40.0220.00733.73
7.1.30.0270.00733.65
7.1.20.0210.01333.82
7.1.10.0060.00915.63
7.1.00.0090.00615.98
7.0.310.0050.00915.36
7.0.300.1340.00613.50
7.0.290.0070.00415.39
7.0.280.0070.00415.40
7.0.270.1570.00315.50
7.0.260.0060.00615.38
7.0.250.0100.00515.24
7.0.240.0040.00815.59
7.0.230.0050.01115.63
7.0.220.0080.00815.48
7.0.210.0000.01515.21
7.0.200.0030.01315.27
7.0.190.0110.00015.28
7.0.180.0040.01115.20
7.0.170.0050.00815.52
7.0.160.0030.00915.54
7.0.150.0090.00315.41
7.0.140.0030.01015.52
7.0.130.0090.00615.29
7.0.120.0000.01415.56
7.0.110.0080.00415.47
7.0.100.0060.00615.36
7.0.90.0040.00815.38
7.0.80.0030.01015.44
7.0.70.1670.01015.24
7.0.60.0060.01215.40
7.0.50.0050.00815.16
7.0.40.0070.00715.36
7.0.30.0110.00315.55
7.0.20.0080.00915.56
7.0.10.0050.00815.38
7.0.00.0060.00615.43

preferences:
36.06 ms | 400 KiB | 5 Q