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){ self::$data['many'] = array(88,99,11); } return self::$data['many'][$this->key]; } public function manys() { if($this->rewind){ 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(); echo PHP_EOL . $it->test() . PHP_EOL . PHP_EOL; echo PHP_EOL . $it->test2() . PHP_EOL . PHP_EOL; $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.0120.00916.63
8.3.50.0100.01016.59
8.3.40.0090.00618.83
8.3.30.0080.00818.97
8.3.20.0080.00020.39
8.3.10.0080.00021.78
8.3.00.0000.00722.12
8.2.180.0130.00318.29
8.2.170.0000.01522.96
8.2.160.0110.00419.21
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00420.93
8.2.120.0080.00026.35
8.2.110.0160.00020.35
8.2.100.0060.00617.79
8.2.90.0040.00419.20
8.2.80.0080.00017.97
8.2.70.0090.00017.63
8.2.60.0000.00818.16
8.2.50.0040.00418.10
8.2.40.0000.00820.47
8.2.30.0040.00421.07
8.2.20.0000.00718.00
8.2.10.0040.00418.18
8.2.00.0000.00818.16
8.1.280.0030.01225.92
8.1.270.0080.00022.06
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.84
8.1.230.0030.00917.71
8.1.220.0000.00817.74
8.1.210.0030.00718.77
8.1.200.0040.00417.23
8.1.190.0080.00017.22
8.1.180.0060.00318.10
8.1.170.0000.00818.95
8.1.160.0040.00419.02
8.1.150.0000.00818.80
8.1.140.0050.00219.50
8.1.130.0050.00218.84
8.1.120.0040.00417.55
8.1.110.0040.00417.45
8.1.100.0000.00717.46
8.1.90.0040.00417.36
8.1.80.0070.00017.46
8.1.70.0030.00317.47
8.1.60.0040.00417.54
8.1.50.0040.00417.52
8.1.40.0030.00617.56
8.1.30.0040.00417.60
8.1.20.0080.00017.66
8.1.10.0040.00417.50
8.1.00.0040.00417.57
8.0.300.0000.00718.77
8.0.290.0050.00316.63
8.0.280.0030.00518.52
8.0.270.0030.00317.19
8.0.260.0000.00616.81
8.0.250.0000.00817.05
8.0.240.0000.00716.90
8.0.230.0000.00716.93
8.0.220.0000.00716.98
8.0.210.0000.00816.97
8.0.200.0060.00016.95
8.0.190.0040.00416.97
8.0.180.0040.00417.00
8.0.170.0040.00417.03
8.0.160.0040.00417.02
8.0.150.0030.00416.97
8.0.140.0070.00016.80
8.0.130.0060.00013.36
8.0.120.0020.00516.93
8.0.110.0040.00417.08
8.0.100.0070.00016.90
8.0.90.0070.00017.04
8.0.80.0060.01616.96
8.0.70.0040.00417.03
8.0.60.0050.00316.83
8.0.50.0040.00416.75
8.0.30.0110.01017.01
8.0.20.0080.01117.40
8.0.10.0000.00717.13
8.0.00.0090.00916.93
7.4.330.0060.00015.55
7.4.320.0000.00716.63
7.4.300.0000.00616.62
7.4.290.0090.00016.43
7.4.280.0060.00316.66
7.4.270.0040.00416.65
7.4.260.0040.00416.64
7.4.250.0070.00016.44
7.4.240.0030.00516.45
7.4.230.0000.00716.73
7.4.220.0110.00716.71
7.4.210.0050.01116.54
7.4.200.0070.00016.51
7.4.160.0120.00516.63
7.4.150.0100.01117.40
7.4.140.0120.00717.86
7.4.130.0080.01116.61
7.4.120.0110.00916.49
7.4.110.0140.00316.45
7.4.100.0030.01416.63
7.4.90.0100.01016.57
7.4.80.0030.01519.39
7.4.70.0060.01016.79
7.4.60.0110.00816.65
7.4.50.0040.01516.65
7.4.40.0120.00616.47
7.4.30.0030.01616.51
7.4.00.0080.00614.93
7.3.330.0030.00313.27
7.3.320.0060.00013.40
7.3.310.0050.00216.26
7.3.300.0020.00516.28
7.3.290.0030.00316.39
7.3.280.0080.00916.37
7.3.270.0140.00617.40
7.3.260.0080.00816.41
7.3.250.0110.00616.60
7.3.240.0020.01516.45
7.3.230.0120.00616.31
7.3.210.0110.01016.52
7.3.200.0060.01216.54
7.3.190.0070.01016.39
7.3.180.0040.01416.48
7.3.170.0070.01016.38
7.3.160.0120.00616.54
7.2.330.0070.01116.83
7.2.320.0120.01216.57
7.2.310.0100.00716.71
7.2.300.0070.01016.58
7.2.290.0100.01316.53
7.2.90.0950.00714.77
7.2.80.0130.00814.78
7.2.70.0330.00714.91
7.2.60.0140.00815.20
7.2.50.1130.00315.05
7.2.40.1270.00915.09
7.2.30.0750.01215.29
7.2.20.0070.01414.89
7.2.10.1470.01314.96
7.2.00.1100.00914.80
7.1.210.0160.00313.86
7.1.200.0850.00713.80
7.1.190.0060.01213.94
7.1.180.1330.00314.04
7.1.170.0980.00713.81
7.1.160.1380.00314.04
7.1.150.0880.01413.96
7.1.140.0130.01013.89
7.1.130.1330.00714.04
7.1.120.0860.00313.95
7.1.110.1130.00714.11
7.1.100.0910.01314.15
7.1.90.0100.00714.04
7.1.80.0030.00913.94
7.1.70.1410.00313.55
7.1.60.0250.01031.89
7.1.50.0230.01631.90
7.1.40.0260.01132.09
7.1.30.0230.01031.96
7.1.20.0300.01131.93
7.1.10.0160.00314.10
7.1.00.0490.01013.76
7.0.310.0680.00713.68
7.0.300.0970.00013.55
7.0.290.0950.00013.70
7.0.280.0070.01313.70
7.0.270.1540.00313.46
7.0.260.0850.00913.54
7.0.250.0790.01013.59
7.0.240.0840.00313.65
7.0.230.0170.00713.33
7.0.220.0400.00613.52
7.0.210.0060.01513.56
7.0.200.0830.00713.67
7.0.190.0190.00813.41
7.0.180.0100.00613.63
7.0.170.0460.00813.57
7.0.160.0810.01013.34
7.0.150.0680.00713.53
7.0.140.0320.00313.70
7.0.130.0040.01413.36
7.0.120.1120.00013.68
7.0.110.0150.00413.71
7.0.100.0140.00313.67
7.0.90.0080.00813.55
7.0.80.0400.00913.73
7.0.70.0130.00313.64
7.0.60.0100.00813.79
7.0.50.0050.01113.75
7.0.40.0330.00713.76
7.0.30.1290.00913.70
7.0.20.0130.00013.61
7.0.10.0110.00313.45
7.0.00.1880.00013.59

preferences:
65.2 ms | 401 KiB | 5 Q