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(); 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.0090.00616.75
8.3.50.0110.00416.36
8.3.40.0070.00718.79
8.3.30.0110.00418.70
8.3.20.0040.00420.33
8.3.10.0100.00023.61
8.3.00.0000.00722.08
8.2.180.0090.01216.34
8.2.170.0090.00622.96
8.2.160.0110.00419.21
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0060.00319.31
8.2.120.0040.00426.35
8.2.110.0060.00320.79
8.2.100.0090.00318.27
8.2.90.0040.00418.28
8.2.80.0040.00417.97
8.2.70.0040.00417.93
8.2.60.0050.00317.93
8.2.50.0030.00518.10
8.2.40.0000.00820.60
8.2.30.0070.00019.44
8.2.20.0050.00318.30
8.2.10.0040.00418.08
8.2.00.0040.00418.15
8.1.280.0130.01025.92
8.1.270.0040.00422.20
8.1.260.0030.00526.35
8.1.250.0030.00528.09
8.1.240.0070.01518.88
8.1.230.0080.00422.74
8.1.220.0030.00617.74
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0060.00317.23
8.1.180.0000.00818.10
8.1.170.0060.00318.53
8.1.160.0040.00419.06
8.1.150.0030.00520.67
8.1.140.0020.00519.49
8.1.130.0070.00018.98
8.1.120.0040.00417.41
8.1.110.0000.00717.42
8.1.100.0050.00317.55
8.1.90.0000.00717.54
8.1.80.0070.00017.46
8.1.70.0040.00417.39
8.1.60.0080.00017.53
8.1.50.0000.00817.47
8.1.40.0000.00917.59
8.1.30.0030.00517.68
8.1.20.0050.00217.59
8.1.10.0030.00617.59
8.1.00.0050.00317.59
8.0.300.0000.00719.69
8.0.290.0040.00416.88
8.0.280.0040.00418.42
8.0.270.0030.00317.34
8.0.260.0030.00316.79
8.0.250.0040.00417.05
8.0.240.0040.00416.94
8.0.230.0000.00917.02
8.0.220.0030.00317.00
8.0.210.0030.00316.93
8.0.200.0030.00316.89
8.0.190.0000.00917.02
8.0.180.0000.00716.97
8.0.170.0040.00416.95
8.0.160.0040.00417.02
8.0.150.0030.00316.79
8.0.140.0050.00216.89
8.0.130.0000.00613.33
8.0.120.0050.00316.92
8.0.110.0000.00816.80
8.0.100.0040.00416.91
8.0.90.0000.00716.91
8.0.80.0100.00716.92
8.0.70.0040.00417.00
8.0.60.0000.00716.91
8.0.50.0000.00716.78
8.0.30.0100.01017.18
8.0.20.0090.01017.40
8.0.10.0080.00016.97
8.0.00.0120.01016.93
7.4.330.0050.00015.55
7.4.320.0030.00316.66
7.4.300.0030.00316.67
7.4.290.0000.00916.69
7.4.280.0030.00516.55
7.4.270.0030.00316.67
7.4.260.0030.00316.64
7.4.250.0040.00416.54
7.4.240.0070.00016.66
7.4.230.0000.00716.30
7.4.220.0090.00916.62
7.4.210.0110.00516.65
7.4.200.0000.00716.39
7.4.160.0110.00616.40
7.4.150.0060.01917.40
7.4.140.0110.00717.86
7.4.130.0110.01616.62
7.4.120.0100.00916.56
7.4.110.0090.00916.54
7.4.100.0060.01216.47
7.4.90.0070.01116.67
7.4.80.0090.01519.39
7.4.70.0100.00716.60
7.4.60.0120.00816.54
7.4.50.0090.00616.50
7.4.40.0120.01216.51
7.4.30.0090.00916.46
7.4.00.0100.00715.05
7.3.330.0000.00613.34
7.3.320.0000.00613.46
7.3.310.0040.00416.37
7.3.300.0030.00316.27
7.3.290.0000.00716.40
7.3.280.0090.00916.39
7.3.270.0100.00717.40
7.3.260.0100.01216.73
7.3.250.0080.01316.46
7.3.240.0150.00316.38
7.3.230.0140.00516.59
7.3.210.0090.00916.61
7.3.200.0130.00316.38
7.3.190.0140.00916.51
7.3.180.0080.00816.29
7.3.170.0070.01316.57
7.3.160.0100.00716.68
7.2.330.0170.00016.79
7.2.320.0170.00016.88
7.2.310.0060.01216.51
7.2.300.0060.01516.49
7.2.290.0110.00616.74
7.2.90.0180.00014.88
7.2.80.0070.00714.70
7.2.70.0090.00615.19
7.2.60.0060.00815.15
7.2.50.2400.00614.95
7.2.40.0660.01415.00
7.2.30.0160.00315.24
7.2.20.0090.00915.29
7.2.10.1970.00615.18
7.2.00.1410.01015.12
7.1.210.1340.00613.74
7.1.200.0230.00613.77
7.1.190.0210.00314.02
7.1.180.0200.00014.03
7.1.170.0160.01013.99
7.1.160.0090.00614.02
7.1.150.0040.01214.06
7.1.140.1770.00714.10
7.1.130.1310.01014.11
7.1.120.1490.00714.05
7.1.110.0110.00613.86
7.1.100.0200.00414.02
7.1.90.0060.01214.10
7.1.80.0100.01013.85
7.1.70.0180.00414.17
7.1.60.0830.01632.03
7.1.50.0540.01232.00
7.1.40.0660.01232.12
7.1.30.0280.01132.03
7.1.20.0700.01032.07
7.1.10.0190.00014.00
7.1.00.2710.01314.07
7.0.310.0030.01013.30
7.0.300.0160.00313.75
7.0.290.0110.00613.44
7.0.280.0110.00613.66
7.0.270.1030.00613.34
7.0.260.0670.00713.68
7.0.250.1400.01313.36
7.0.240.0060.00813.71
7.0.230.0180.00413.61
7.0.220.0120.00313.48
7.0.210.0100.00313.60
7.0.200.0640.00913.47
7.0.190.0100.00613.67
7.0.180.1800.01013.59
7.0.170.2220.00013.36
7.0.160.2090.00713.43
7.0.150.0080.01113.66
7.0.140.2240.00313.66
7.0.130.1890.00013.68
7.0.120.1630.01013.72
7.0.110.1130.00313.38
7.0.100.0310.01113.57
7.0.90.0120.00613.63
7.0.80.0500.01013.54
7.0.70.0060.00913.42
7.0.60.1850.00713.66
7.0.50.1590.00213.86
7.0.40.1790.01013.75
7.0.30.1010.00313.34
7.0.20.0710.00313.60
7.0.10.0060.01413.48
7.0.00.0100.01013.42

preferences:
51.94 ms | 401 KiB | 5 Q