3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private static $data; private $var = array(1,2,3); private $current; private $rewind; 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]; } } public function many() { if($this->rewind){ echo 'VAR2' . PHP_EOL; self::$data['many'] = array(88,99,11); } return self::$data['many'][$this->key]; } public function manys() { if($this->rewind){ echo 'VAR' . PHP_EOL; self::$data['manys'] = array(55,66,77); } return self::$data['manys'][$this->key]; } public function rewind() { self::$data = null; $this->rewind = true; 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"; $this->rewind = false; 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(); } public function test2(){ return $this->manys(); } } $it = new foo(); foreach ($it as $a => $b) { echo PHP_EOL . $it->test() . PHP_EOL . PHP_EOL; echo PHP_EOL . $it->test2() . 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.0000.01516.63
8.3.50.0100.01016.47
8.3.40.0120.00318.83
8.3.30.0140.00018.78
8.3.20.0050.00320.38
8.3.10.0080.00021.91
8.3.00.0040.00422.09
8.2.180.0110.00716.75
8.2.170.0070.01022.96
8.2.160.0140.00319.21
8.2.150.0040.01124.18
8.2.140.0000.00824.66
8.2.130.0040.00421.05
8.2.120.0060.00326.16
8.2.110.0040.00719.45
8.2.100.0080.00418.16
8.2.90.0000.00819.19
8.2.80.0080.00018.03
8.2.70.0030.00617.50
8.2.60.0060.00317.93
8.2.50.0040.00418.10
8.2.40.0060.00320.60
8.2.30.0050.00321.08
8.2.20.0020.00518.16
8.2.10.0040.00418.01
8.2.00.0050.00218.13
8.1.280.0120.00925.92
8.1.270.0040.00423.83
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0120.00923.78
8.1.230.0110.00317.51
8.1.220.0050.00317.78
8.1.210.0060.00318.77
8.1.200.0060.00317.23
8.1.190.0050.00317.23
8.1.180.0040.00418.10
8.1.170.0040.00418.98
8.1.160.0030.00319.02
8.1.150.0000.00718.95
8.1.140.0000.00719.48
8.1.130.0000.00818.74
8.1.120.0000.00817.37
8.1.110.0040.00417.32
8.1.100.0060.00317.53
8.1.90.0050.00217.45
8.1.80.0040.00417.54
8.1.70.0040.00417.36
8.1.60.0000.00817.49
8.1.50.0040.00417.54
8.1.40.0030.00517.49
8.1.30.0030.00617.69
8.1.20.0080.00017.66
8.1.10.0030.00517.59
8.1.00.0000.00817.50
8.0.300.0070.00018.77
8.0.290.0050.00216.75
8.0.280.0000.00818.36
8.0.270.0000.00717.31
8.0.260.0000.01016.73
8.0.250.0070.00017.03
8.0.240.0000.00716.93
8.0.230.0040.00416.86
8.0.220.0030.00316.82
8.0.210.0050.00216.91
8.0.200.0000.00716.85
8.0.190.0040.00416.87
8.0.180.0040.00416.97
8.0.170.0040.00416.93
8.0.160.0030.00516.88
8.0.150.0050.00216.85
8.0.140.0000.00816.91
8.0.130.0040.00413.31
8.0.120.0020.00516.88
8.0.110.0040.00416.89
8.0.100.0040.00416.75
8.0.90.0050.00316.79
8.0.80.0140.00716.88
8.0.70.0000.00816.89
8.0.60.0040.00416.89
8.0.50.0000.00716.95
8.0.30.0080.00917.15
8.0.20.0120.01017.40
8.0.10.0040.00416.80
8.0.00.0110.00716.79
7.4.330.0000.00515.55
7.4.320.0070.00016.41
7.4.300.0030.00316.41
7.4.290.0050.00316.51
7.4.280.0000.00816.46
7.4.270.0070.00016.62
7.4.260.0070.00016.42
7.4.250.0000.00816.45
7.4.240.0040.00416.46
7.4.230.0000.00716.58
7.4.220.0110.00616.52
7.4.210.0110.00316.56
7.4.200.0000.00816.47
7.4.160.0110.00816.45
7.4.150.0190.00017.40
7.4.140.0070.01217.86
7.4.130.0060.01316.54
7.4.120.0100.01016.47
7.4.110.0120.00616.64
7.4.100.0090.00916.62
7.4.90.0030.01616.55
7.4.80.0130.01019.39
7.4.70.0030.01316.42
7.4.60.0090.00616.53
7.4.50.0030.01216.47
7.4.40.0120.00916.59
7.4.30.0060.01216.40
7.4.10.0080.01014.75
7.4.00.0080.00915.03
7.3.330.0000.00613.35
7.3.320.0000.00613.41
7.3.310.0030.00316.42
7.3.300.0000.00716.39
7.3.290.0070.00616.37
7.3.280.0090.00916.38
7.3.270.0170.00717.40
7.3.260.0160.00316.44
7.3.250.0100.01016.41
7.3.240.0100.00716.44
7.3.230.0040.01316.34
7.3.210.0100.00716.58
7.3.200.0090.01216.34
7.3.190.0120.00616.67
7.3.180.0080.00816.65
7.3.170.0070.01016.50
7.3.160.0140.00316.38
7.3.130.0070.00814.74
7.3.120.0070.00915.05
7.3.110.0080.01014.86
7.3.100.0050.01014.98
7.3.90.0050.01314.82
7.3.80.0100.00815.04
7.3.70.0090.00514.72
7.3.60.0040.00914.70
7.3.50.0050.00614.87
7.3.40.0020.01314.88
7.3.30.0100.00314.87
7.3.20.0020.01316.75
7.3.10.0040.01116.72
7.3.00.0010.01216.72
7.2.330.0080.01116.75
7.2.320.0150.00416.58
7.2.310.0120.00616.90
7.2.300.0100.00716.54
7.2.290.0120.00416.87
7.2.260.0070.01215.26
7.2.250.0070.01215.39
7.2.240.0030.01015.05
7.2.230.0050.01415.20
7.2.220.0110.00615.19
7.2.210.0000.01115.12
7.2.200.0090.00715.10
7.2.190.0030.01415.02
7.2.180.0050.00815.20
7.2.170.0030.01015.21
7.2.160.0050.00514.99
7.2.150.0050.01016.81
7.2.140.0060.01216.98
7.2.130.0070.00916.94
7.2.120.0060.00816.90
7.2.110.0090.00617.04
7.2.100.0070.00716.83
7.2.90.0130.00316.22
7.2.80.0350.01016.30
7.2.70.0230.01516.41
7.2.60.0250.00616.30
7.2.50.0300.00616.27
7.2.40.0070.00916.45
7.2.30.0070.00816.32
7.2.20.0420.00516.31
7.2.10.0290.00716.22
7.2.00.0140.00716.35
7.1.330.0050.00815.77
7.1.320.0080.00815.72
7.1.310.0050.00815.77
7.1.300.0020.01315.52
7.1.290.0080.00615.88
7.1.280.0060.00615.71
7.1.270.0070.00515.67
7.1.260.0050.01015.76
7.1.250.0090.00715.69
7.1.240.0090.00715.74
7.1.230.0050.00915.80
7.1.220.0030.01015.77
7.1.210.0300.00715.34
7.1.200.0310.00815.15
7.1.190.0060.00715.04
7.1.180.0210.00915.22
7.1.170.0200.00715.27
7.1.160.0140.00415.30
7.1.150.0110.00315.28
7.1.140.0310.00615.11
7.1.130.0450.00415.24
7.1.120.0100.00315.13
7.1.110.0360.00115.21
7.1.100.0350.00815.15
7.1.90.0030.00915.30
7.1.80.0300.00615.18
7.1.70.0320.00615.17
7.1.60.0110.01021.20
7.1.50.0340.00521.22
7.1.40.0270.00321.17
7.1.30.0160.00821.25
7.1.20.0160.00921.19
7.1.10.0110.00515.22
7.1.00.0280.00915.09
7.0.330.0030.00715.29
7.0.320.0060.00915.45
7.0.310.0430.00914.72
7.0.300.0090.00514.84
7.0.290.0270.00814.65
7.0.280.0280.00514.76
7.0.270.0400.00614.84
7.0.260.0040.00914.81
7.0.250.0090.00614.90
7.0.240.0400.00714.86
7.0.230.0280.00514.92
7.0.220.0220.01114.66
7.0.210.0080.00714.79
7.0.200.0070.00914.80
7.0.190.0300.00614.87
7.0.180.0400.00814.59
7.0.170.0130.00614.85
7.0.160.0410.00914.83
7.0.150.0080.00414.86
7.0.140.0060.00914.95
7.0.130.0060.00814.73
7.0.120.0150.01014.93
7.0.110.0240.00214.91
7.0.100.0090.00914.78
7.0.90.0070.00514.79
7.0.80.0210.00814.76
7.0.70.0050.00614.95
7.0.60.0040.01114.87
7.0.50.0320.00714.84
7.0.40.0100.00613.61
7.0.30.0450.00713.60
7.0.20.0560.00713.50
7.0.10.0470.00613.67
7.0.00.0430.00813.46
5.6.400.0040.00614.56
5.6.390.0050.00914.56
5.6.380.0090.00614.53
5.6.370.0080.00214.55
5.6.360.0020.00914.50
5.6.350.0110.00314.47
5.6.340.0090.00414.55
5.6.330.0040.00714.77
5.6.320.0050.01114.31
5.6.310.0000.00914.33
5.6.300.0020.00814.57
5.6.290.0050.00714.56
5.6.280.0100.00514.38
5.6.270.0060.01114.64
5.6.260.0040.01314.69
5.6.250.0060.00614.62
5.6.240.0060.00714.60
5.6.230.0070.00514.70
5.6.220.0040.00714.38
5.6.210.0070.00714.59
5.6.200.0050.01114.55
5.6.190.0060.00614.30
5.6.180.0050.01014.45
5.6.170.0050.00714.40
5.6.160.0060.00814.30
5.6.150.0070.00514.76
5.6.140.0040.01114.54
5.6.130.0030.01214.56
5.6.120.0030.01014.34
5.6.110.0060.00714.36
5.6.100.0080.00814.36
5.6.90.0070.01014.64
5.6.80.0070.00814.23
5.6.70.0090.00614.38
5.6.60.0070.00614.38
5.6.50.0080.00514.50
5.6.40.0090.00514.53
5.6.30.0080.00614.54
5.6.20.0080.00714.38
5.6.10.0050.00714.19
5.6.00.0020.01314.49

preferences:
62.56 ms | 401 KiB | 5 Q