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 ($this->var[$name]) { return $this->var[$name]; } if ($name == 'test') { $class = get_called_class(); return $this->var[$name] = (new $class())->$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.70.0090.01216.75
8.3.60.0120.00916.88
8.3.50.0090.01116.72
8.3.40.0040.01118.92
8.3.30.0110.00418.92
8.3.20.0050.00320.30
8.3.10.0080.00023.30
8.3.00.0080.00022.14
8.2.180.0150.00317.13
8.2.170.0120.00322.96
8.2.160.0150.00619.08
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0070.00420.94
8.2.120.0040.00426.35
8.2.110.0030.00622.31
8.2.100.0140.00018.03
8.2.90.0030.00619.21
8.2.80.0080.00017.97
8.2.70.0000.00817.63
8.2.60.0040.00418.05
8.2.50.0000.00819.74
8.2.40.0000.00820.60
8.2.30.0040.00419.29
8.2.20.0000.00718.27
8.2.10.0000.00818.04
8.2.00.0050.00218.07
8.1.280.0120.00625.92
8.1.270.0040.00422.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00621.00
8.1.230.0070.00419.10
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0070.00317.48
8.1.190.0080.00017.22
8.1.180.0040.00418.10
8.1.170.0090.00018.50
8.1.160.0040.00419.05
8.1.150.0000.00820.59
8.1.140.0070.00019.63
8.1.130.0030.00319.01
8.1.120.0050.00217.48
8.1.110.0030.00617.50
8.1.100.0000.00817.46
8.1.90.0030.00517.53
8.1.80.0040.00417.48
8.1.70.0050.00217.52
8.1.60.0040.00417.54
8.1.50.0080.00017.46
8.1.40.0030.00617.45
8.1.30.0080.00017.63
8.1.20.0000.00817.68
8.1.10.0090.00017.60
8.1.00.0050.00317.61
8.0.300.0000.00720.07
8.0.290.0000.00816.88
8.0.280.0000.00718.53
8.0.270.0040.00417.31
8.0.260.0060.00016.88
8.0.250.0000.00716.94
8.0.240.0040.00417.03
8.0.230.0000.00817.09
8.0.220.0030.00317.04
8.0.210.0030.00416.99
8.0.200.0000.00717.04
8.0.190.0000.00816.95
8.0.180.0050.00317.09
8.0.170.0040.00416.96
8.0.160.0000.00917.02
8.0.150.0040.00416.99
8.0.140.0000.00716.85
8.0.130.0000.00613.46
8.0.120.0040.00416.87
8.0.110.0050.00216.90
8.0.100.0000.00717.06
8.0.90.0000.00716.82
8.0.80.0070.01017.04
8.0.70.0030.00517.00
8.0.60.0030.00517.02
8.0.50.0030.00516.90
8.0.30.0070.01117.02
8.0.20.0140.00917.40
8.0.10.0000.01016.97
8.0.00.0060.01616.80
7.4.330.0020.00215.55
7.4.320.0030.00316.56
7.4.300.0000.00616.69
7.4.290.0030.00316.64
7.4.280.0020.00516.59
7.4.270.0000.00716.55
7.4.260.0070.00016.46
7.4.250.0070.00016.60
7.4.240.0000.00716.58
7.4.230.0070.00016.52
7.4.220.0090.00916.50
7.4.210.0050.00916.71
7.4.200.0000.00816.63
7.4.160.0070.00916.65
7.4.150.0150.00917.40
7.4.140.0110.00717.86
7.4.130.0140.00616.71
7.4.120.0060.01416.56
7.4.110.0100.01016.41
7.4.100.0090.00916.48
7.4.90.0120.00616.39
7.4.80.0090.00919.39
7.4.70.0030.01316.50
7.4.60.0100.00616.61
7.4.50.0060.01016.40
7.4.40.0070.01016.73
7.4.30.0060.01416.30
7.4.00.0070.00715.33
7.3.330.0040.00413.27
7.3.320.0000.00613.44
7.3.310.0000.00816.33
7.3.300.0050.00216.41
7.3.290.0040.00416.31
7.3.280.0100.00816.44
7.3.270.0190.00017.40
7.3.260.0080.01116.58
7.3.250.0090.01016.45
7.3.240.0070.01116.53
7.3.230.0140.00416.46
7.3.210.0070.01316.50
7.3.200.0100.00716.42
7.3.190.0030.01316.42
7.3.180.0100.00716.48
7.3.170.0110.00516.68
7.3.160.0090.00616.50
7.2.330.0100.01016.69
7.2.320.0060.01116.49
7.2.310.0140.00716.78
7.2.300.0060.01216.54
7.2.290.0110.00816.82
7.2.90.0950.00314.89
7.2.80.0980.00014.88
7.2.70.0890.00615.09
7.2.60.0870.00315.23
7.2.50.0900.00715.13
7.2.40.1510.00715.24
7.2.30.0760.00715.21
7.2.20.0130.00715.13
7.2.10.1030.00715.09
7.2.00.0970.02014.89
7.1.210.0770.01014.02
7.1.200.0080.00513.99
7.1.190.1240.00313.90
7.1.180.0910.00314.20
7.1.170.0720.00713.81
7.1.160.0930.00714.15
7.1.150.0750.00714.13
7.1.140.0770.00713.73
7.1.130.1010.00713.92
7.1.120.0140.00414.12
7.1.110.0990.00313.86
7.1.100.0360.00614.07
7.1.90.1830.00713.92
7.1.80.0140.00713.97
7.1.70.0160.00814.00
7.1.60.0290.00732.06
7.1.50.1310.01031.95
7.1.40.0910.01332.03
7.1.30.1570.01331.95
7.1.20.0550.01031.72
7.1.10.0790.00913.92
7.1.00.0760.00313.82
7.0.310.0670.00313.48
7.0.300.1010.00313.53
7.0.290.1220.00313.50
7.0.280.0790.01013.44
7.0.270.0810.00613.59
7.0.260.0690.00913.57
7.0.250.0860.00713.44
7.0.240.1290.00613.44
7.0.230.1280.00313.73
7.0.220.0560.01213.44
7.0.210.0960.00313.70
7.0.200.0170.00613.62
7.0.190.0910.01013.57
7.0.180.1490.01013.52
7.0.170.1050.00713.44
7.0.160.1210.01013.50
7.0.150.0840.00313.46
7.0.140.0900.00313.67
7.0.130.0820.01013.73
7.0.120.1390.00713.47
7.0.110.1230.00613.69
7.0.100.0840.00613.68
7.0.90.0930.00713.48
7.0.80.0960.00713.30
7.0.70.0830.00713.56
7.0.60.0940.00913.29
7.0.50.0890.00613.79
7.0.40.1040.00613.80
7.0.30.1630.01313.61
7.0.20.2050.01013.80
7.0.10.1420.00613.76
7.0.00.1410.00313.63

preferences:
40.32 ms | 401 KiB | 5 Q