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 = array(88,99,11); } return self::$data[$this->key]; } public function manys() { if($this->rewind){ echo 'VAR' . PHP_EOL; self::$data = array(55,66,77); } return self::$data[$this->key]; } public function rewind() { self::$data = null; $this->rewind = 1; 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"; if(! $var){ var_dump($var); $this->rewind = 0; } 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.0040.01116.63
8.3.50.0150.00316.50
8.3.40.0110.00718.97
8.3.30.0040.01118.80
8.3.20.0040.00420.11
8.3.10.0000.00821.85
8.3.00.0040.00421.98
8.2.180.0150.00616.47
8.2.170.0110.01122.96
8.2.160.0070.00719.21
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0050.00321.18
8.2.120.0000.00826.35
8.2.110.0030.00720.52
8.2.100.0090.00317.81
8.2.90.0030.00619.22
8.2.80.0000.00817.97
8.2.70.0060.00317.63
8.2.60.0030.00617.79
8.2.50.0000.00818.10
8.2.40.0040.00420.60
8.2.30.0040.00419.32
8.2.20.0040.00418.13
8.2.10.0020.00518.01
8.2.00.0040.00418.14
8.1.280.0090.00925.92
8.1.270.0070.00021.95
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00623.88
8.1.230.0060.00617.70
8.1.220.0080.00017.76
8.1.210.0000.00918.77
8.1.200.0030.00717.38
8.1.190.0000.00817.22
8.1.180.0040.00418.10
8.1.170.0080.00019.04
8.1.160.0000.00718.91
8.1.150.0030.00618.87
8.1.140.0050.00219.67
8.1.130.0090.00018.94
8.1.120.0000.00717.53
8.1.110.0000.00817.33
8.1.100.0040.00417.48
8.1.90.0000.00817.55
8.1.80.0000.00717.38
8.1.70.0080.00017.52
8.1.60.0000.00917.58
8.1.50.0000.00817.52
8.1.40.0000.00817.51
8.1.30.0000.00717.73
8.1.20.0040.00417.71
8.1.10.0000.00917.49
8.1.00.0040.00417.54
8.0.300.0080.00018.77
8.0.290.0040.00416.75
8.0.280.0000.00718.39
8.0.270.0070.00017.32
8.0.260.0040.00416.83
8.0.250.0030.00316.96
8.0.240.0040.00416.95
8.0.230.0030.00316.97
8.0.220.0030.00316.95
8.0.210.0040.00416.80
8.0.200.0040.00416.97
8.0.190.0000.00817.01
8.0.180.0040.00416.93
8.0.170.0000.00716.94
8.0.160.0000.00716.99
8.0.150.0040.00416.77
8.0.140.0000.00716.80
8.0.130.0050.00013.33
8.0.120.0040.00416.86
8.0.110.0000.00716.90
8.0.100.0000.00816.80
8.0.90.0000.00816.80
8.0.80.0100.01316.80
8.0.70.0040.00416.91
8.0.60.0000.00816.73
8.0.50.0050.00316.89
8.0.30.0120.00617.04
8.0.20.0110.00817.42
8.0.10.0040.00417.10
8.0.00.0090.00916.70
7.4.330.0000.00515.55
7.4.320.0060.00016.54
7.4.300.0030.00316.61
7.4.290.0040.00416.53
7.4.280.0000.00716.60
7.4.270.0000.00716.53
7.4.260.0070.00016.53
7.4.250.0040.00416.58
7.4.240.0070.00016.57
7.4.230.0000.00716.72
7.4.220.0090.00916.73
7.4.210.0070.00716.61
7.4.200.0040.00416.38
7.4.160.0050.01116.54
7.4.150.0080.01117.40
7.4.140.0080.01117.86
7.4.130.0100.01116.59
7.4.120.0100.01216.50
7.4.110.0090.00916.57
7.4.100.0090.01416.62
7.4.90.0120.00416.62
7.4.80.0100.00719.39
7.4.70.0030.01316.57
7.4.60.0030.01216.43
7.4.50.0140.00416.39
7.4.40.0040.01316.49
7.4.30.0060.01216.57
7.4.00.0100.00714.76
7.3.330.0070.00013.39
7.3.320.0060.00013.39
7.3.310.0040.00416.38
7.3.300.0070.00016.35
7.3.290.0080.01116.38
7.3.280.0070.00916.39
7.3.270.0060.01117.40
7.3.260.0120.01016.42
7.3.250.0110.01016.51
7.3.240.0090.00816.64
7.3.230.0090.00916.36
7.3.210.0100.00616.48
7.3.200.0040.01816.60
7.3.190.0040.01216.48
7.3.180.0130.00316.52
7.3.170.0120.00616.42
7.3.160.0090.00916.64
7.3.10.0160.00816.50
7.3.00.0120.00816.74
7.2.330.0060.01216.83
7.2.320.0090.00916.98
7.2.310.0060.01216.87
7.2.300.0100.01116.55
7.2.290.0100.01316.88
7.2.130.0120.00716.84
7.2.120.0110.00916.97
7.2.110.0060.01217.05
7.2.100.0090.00816.81
7.2.90.0270.00916.22
7.2.80.0250.00716.18
7.2.70.0310.00816.35
7.2.60.0270.00516.45
7.2.50.0210.00716.32
7.2.40.0110.01116.46
7.2.30.0280.00416.24
7.2.20.0250.00716.23
7.2.10.0140.00816.12
7.2.00.0200.00816.36
7.1.250.0040.00915.67
7.1.210.0500.00313.91
7.1.200.0480.00613.84
7.1.190.0380.00814.28
7.1.180.0480.00314.18
7.1.170.0830.00614.03
7.1.160.0710.00414.15
7.1.150.0120.00914.02
7.1.140.0800.00613.89
7.1.130.0030.01014.05
7.1.120.0070.01113.90
7.1.110.0790.00714.12
7.1.100.0580.00313.80
7.1.90.0090.00913.80
7.1.80.0730.01014.14
7.1.70.0120.00814.13
7.1.60.0690.01632.13
7.1.50.0750.02232.01
7.1.40.0510.00332.10
7.1.30.0620.00831.91
7.1.20.0890.00731.96
7.1.10.0920.00613.78
7.1.00.0720.00313.88
7.0.310.0500.00713.49
7.0.300.0170.00813.61
7.0.290.0530.00713.81
7.0.280.0100.00513.57
7.0.270.0360.00013.65
7.0.260.0090.00613.71
7.0.250.0550.00313.35
7.0.240.0540.00313.74
7.0.230.0090.00313.63
7.0.220.0070.01113.79
7.0.210.0820.00613.64
7.0.200.0770.00613.74
7.0.190.0100.00713.77
7.0.180.0120.00613.70
7.0.170.1140.00913.71
7.0.160.0080.00813.54
7.0.150.0730.01013.69
7.0.140.0030.01413.45
7.0.130.0110.00713.77
7.0.120.0220.00013.59
7.0.110.0140.00713.70
7.0.100.0270.01013.27
7.0.90.0560.00313.70
7.0.80.0320.01213.46
7.0.70.0120.00913.68
7.0.60.0090.00513.64
7.0.50.0140.00413.93
7.0.40.0840.00313.50
7.0.30.0640.00613.71
7.0.20.0670.00613.77
7.0.10.0590.00713.80
7.0.00.0580.00313.75

preferences:
41.89 ms | 401 KiB | 5 Q