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') { $class = get_called_class(); echo $class . PHP_EOL; return $this->var[$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.0070.01116.75
8.3.50.0040.01116.71
8.3.40.0110.00318.76
8.3.30.0090.00618.91
8.3.20.0030.00520.20
8.3.10.0000.01123.66
8.3.00.0000.00722.05
8.2.180.0040.01525.92
8.2.170.0110.00722.96
8.2.160.0070.00719.27
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0050.00321.00
8.2.120.0000.00826.35
8.2.110.0000.00922.15
8.2.100.0090.00317.91
8.2.90.0040.00419.31
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0030.00518.16
8.2.50.0060.00318.10
8.2.40.0000.00920.54
8.2.30.0050.00219.49
8.2.20.0000.00718.05
8.2.10.0000.00818.03
8.2.00.0050.00218.09
8.1.280.0080.00825.92
8.1.270.0080.00022.24
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0080.00024.02
8.1.230.0040.00717.95
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0070.00317.38
8.1.190.0000.00817.25
8.1.180.0000.00818.10
8.1.170.0040.00418.65
8.1.160.0030.00518.94
8.1.150.0000.00820.80
8.1.140.0040.00419.59
8.1.130.0030.00318.94
8.1.120.0040.00417.53
8.1.110.0000.00817.31
8.1.100.0080.00017.46
8.1.90.0040.00417.54
8.1.80.0070.00017.49
8.1.70.0030.00517.41
8.1.60.0060.00317.62
8.1.50.0050.00317.56
8.1.40.0000.00917.59
8.1.30.0030.00517.58
8.1.20.0030.00517.73
8.1.10.0000.00817.65
8.1.00.0030.00617.47
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0030.00318.40
8.0.270.0080.00017.22
8.0.260.0030.00316.86
8.0.250.0030.00316.97
8.0.240.0050.00216.97
8.0.230.0050.00516.87
8.0.220.0000.00716.94
8.0.210.0000.00716.94
8.0.200.0030.00316.93
8.0.190.0000.00816.98
8.0.180.0040.00416.98
8.0.170.0040.00416.98
8.0.160.0060.00316.95
8.0.150.0060.00316.79
8.0.140.0070.00016.80
8.0.130.0040.00413.30
8.0.120.0000.00816.82
8.0.110.0050.00316.80
8.0.100.0040.00416.97
8.0.90.0070.00016.82
8.0.80.0100.00716.99
8.0.70.0080.00016.97
8.0.60.0030.00516.72
8.0.50.0020.00516.84
8.0.30.0110.00617.12
8.0.20.0130.00817.42
8.0.10.0040.00416.86
8.0.00.0030.01616.93
7.4.330.0050.00015.55
7.4.320.0030.00316.55
7.4.300.0030.00316.62
7.4.290.0040.00416.66
7.4.280.0030.00616.65
7.4.270.0050.00316.64
7.4.260.0080.00016.66
7.4.250.0030.00316.66
7.4.240.0040.00416.57
7.4.230.0030.00316.73
7.4.220.0120.00616.61
7.4.210.0070.00816.61
7.4.200.0040.00416.39
7.4.160.0060.01016.60
7.4.150.0140.00617.40
7.4.140.0070.01317.86
7.4.130.0120.01216.69
7.4.120.0100.00916.55
7.4.110.0120.00616.53
7.4.100.0120.01216.72
7.4.90.0060.01216.80
7.4.80.0100.00619.39
7.4.70.0170.00016.32
7.4.60.0150.01216.74
7.4.50.0060.00916.64
7.4.40.0160.00816.39
7.4.30.0160.00316.70
7.4.00.0070.01015.11
7.3.330.0030.00313.22
7.3.320.0030.00313.38
7.3.310.0020.00516.29
7.3.300.0030.00316.49
7.3.290.0000.00716.25
7.3.280.0080.00916.35
7.3.270.0140.00417.40
7.3.260.0170.00316.36
7.3.250.0110.01216.44
7.3.240.0030.01416.38
7.3.230.0060.01116.59
7.3.210.0140.00316.52
7.3.200.0060.01116.47
7.3.190.0030.01316.44
7.3.180.0140.00816.62
7.3.170.0090.01216.52
7.3.160.0130.00316.41
7.3.120.0040.01515.05
7.3.110.0140.00415.00
7.3.100.0080.01214.81
7.3.90.0060.00614.77
7.3.80.0110.00414.98
7.3.70.0030.00814.74
7.3.60.0080.00814.59
7.3.50.0070.00714.76
7.3.40.0000.01414.90
7.3.30.0030.01014.90
7.3.20.0070.00416.67
7.3.10.0080.00616.63
7.3.00.0040.00816.65
7.2.330.0090.00916.75
7.2.320.0090.00916.50
7.2.310.0060.01616.64
7.2.300.0030.01616.65
7.2.290.0000.01716.70
7.2.250.0130.00714.94
7.2.240.0060.00915.22
7.2.230.0100.00314.82
7.2.220.0090.00015.22
7.2.210.0000.02115.00
7.2.200.0090.00315.09
7.2.190.0070.00714.99
7.2.180.0070.00715.24
7.2.170.0130.00615.15
7.2.130.0000.01616.91
7.2.120.0090.00717.05
7.2.110.0070.00516.96
7.2.100.0070.00716.86
7.2.90.0060.00616.22
7.2.80.0260.00816.32
7.2.70.0170.00816.45
7.2.60.0120.00716.48
7.2.50.0110.01016.19
7.2.40.0130.00816.22
7.2.30.0100.00616.36
7.2.20.0120.00716.34
7.2.10.0180.00616.40
7.2.00.0340.01016.28
7.1.330.0090.00615.82
7.1.320.0000.01015.71
7.1.310.0070.00715.79
7.1.300.0120.00315.76
7.1.290.0030.01416.00
7.1.280.0070.01015.80
7.1.270.0120.00315.78
7.1.260.0090.00315.86
7.1.250.0070.00715.87
7.1.210.0260.00313.96
7.1.200.0540.00314.06
7.1.190.1020.00313.68
7.1.180.0760.00414.01
7.1.170.0130.00014.14
7.1.160.0130.00614.04
7.1.150.0060.00614.11
7.1.140.0270.00514.07
7.1.130.0070.00714.02
7.1.120.0060.00613.95
7.1.110.0790.00614.01
7.1.100.1020.00713.95
7.1.90.0240.00014.10
7.1.80.0980.00613.86
7.1.70.1730.00314.08
7.1.60.1470.00332.12
7.1.50.0090.02731.99
7.1.40.0340.01532.09
7.1.30.0420.01731.97
7.1.20.0290.01931.65
7.1.10.0670.01013.86
7.1.00.0120.00914.11
7.0.310.0090.00913.66
7.0.300.0300.00313.45
7.0.290.0140.01413.36
7.0.280.0150.00013.42
7.0.270.0080.00413.45
7.0.260.0350.01013.61
7.0.250.0060.00913.52
7.0.240.0110.00413.80
7.0.230.0090.00713.53
7.0.220.1210.00713.54
7.0.210.1350.00913.63
7.0.200.1390.00313.70
7.0.190.0270.01013.44
7.0.180.0880.00713.65
7.0.170.4500.00713.75
7.0.160.0940.00613.79
7.0.150.1980.01613.70
7.0.140.0060.01113.66
7.0.130.4610.01013.67
7.0.120.0090.00913.55
7.0.110.0230.00013.39
7.0.100.0810.00013.59
7.0.90.2200.00613.62
7.0.80.0830.00713.39
7.0.70.1010.00313.72
7.0.60.3700.00613.80
7.0.50.0100.00913.59
7.0.40.3970.00613.68
7.0.30.3510.01013.71
7.0.20.3000.01313.77
7.0.10.2550.00713.77
7.0.00.3350.01013.65

preferences:
41.86 ms | 401 KiB | 5 Q