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(); 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.00316.75
8.3.50.0130.00316.29
8.3.40.0110.00418.67
8.3.30.0070.00718.71
8.3.20.0040.00420.34
8.3.10.0080.00021.73
8.3.00.0080.00021.97
8.2.180.0070.00716.50
8.2.170.0090.00922.96
8.2.160.0070.00719.06
8.2.150.0130.00324.18
8.2.140.0030.00524.66
8.2.130.0070.00020.94
8.2.120.0040.00426.35
8.2.110.0070.00321.04
8.2.100.0040.00718.22
8.2.90.0050.00319.34
8.2.80.0080.00017.97
8.2.70.0080.00017.50
8.2.60.0040.00418.05
8.2.50.0030.00518.10
8.2.40.0000.00720.63
8.2.30.0080.00021.02
8.2.20.0040.00418.20
8.2.10.0040.00418.02
8.2.00.0040.00418.13
8.1.280.0130.01025.92
8.1.270.0050.00323.97
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0060.00323.86
8.1.230.0110.00017.42
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0040.00417.36
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0040.00419.03
8.1.160.0050.00218.91
8.1.150.0060.00320.68
8.1.140.0040.00419.63
8.1.130.0030.00518.95
8.1.120.0000.00717.47
8.1.110.0050.00217.36
8.1.100.0040.00417.36
8.1.90.0040.00417.45
8.1.80.0040.00417.55
8.1.70.0000.00917.54
8.1.60.0090.00017.55
8.1.50.0030.00617.56
8.1.40.0030.00617.38
8.1.30.0050.00317.68
8.1.20.0040.00417.65
8.1.10.0080.00017.57
8.1.00.0080.00017.54
8.0.300.0040.00418.77
8.0.290.0050.00216.63
8.0.280.0040.00418.45
8.0.270.0040.00417.27
8.0.260.0050.00216.75
8.0.250.0040.00416.85
8.0.240.0000.00816.95
8.0.230.0030.00316.92
8.0.220.0030.00316.93
8.0.210.0050.00216.78
8.0.200.0000.00816.99
8.0.190.0000.00816.99
8.0.180.0060.00316.95
8.0.170.0050.00216.98
8.0.160.0000.00816.87
8.0.150.0070.00016.79
8.0.140.0030.00616.87
8.0.130.0030.00313.38
8.0.120.0060.00316.88
8.0.110.0070.00016.84
8.0.100.0000.00716.78
8.0.90.0000.00816.80
8.0.80.0060.01916.87
8.0.70.0020.00516.77
8.0.60.0040.00416.89
8.0.50.0040.00416.93
8.0.30.0060.01217.14
8.0.20.0130.00717.40
8.0.10.0020.00516.96
8.0.00.0060.01216.65
7.4.330.0030.00315.55
7.4.320.0030.00316.66
7.4.300.0060.00016.62
7.4.290.0040.00416.52
7.4.280.0030.00516.60
7.4.270.0040.00416.60
7.4.260.0000.00716.55
7.4.250.0050.00316.61
7.4.240.0080.00016.54
7.4.230.0030.00316.60
7.4.220.0070.01116.73
7.4.210.0040.01216.70
7.4.200.0040.00416.52
7.4.160.0080.00816.46
7.4.150.0150.00317.40
7.4.140.0130.00617.86
7.4.130.0110.00816.36
7.4.120.0120.00716.64
7.4.110.0080.00816.64
7.4.100.0080.01316.47
7.4.90.0100.00716.71
7.4.80.0110.00719.39
7.4.70.0140.00316.52
7.4.60.0090.01616.66
7.4.50.0000.01916.47
7.4.40.0090.00616.40
7.4.30.0100.01016.55
7.4.10.0040.01214.79
7.4.00.0010.01314.99
7.3.330.0000.00513.40
7.3.320.0030.00313.38
7.3.310.0050.00316.30
7.3.300.0040.00416.42
7.3.290.0090.00616.42
7.3.280.0090.00816.40
7.3.270.0120.01217.40
7.3.260.0080.00816.48
7.3.250.0100.01116.45
7.3.240.0160.00616.38
7.3.230.0090.00616.41
7.3.210.0100.01016.67
7.3.200.0100.00616.64
7.3.190.0070.00916.48
7.3.180.0060.00916.40
7.3.170.0110.00616.41
7.3.160.0070.01316.54
7.3.130.0070.01014.69
7.3.120.0100.00714.92
7.3.110.0000.01314.95
7.3.100.0120.00014.98
7.3.90.0100.00314.91
7.3.80.0030.01014.97
7.3.70.0090.00014.56
7.3.60.0040.01114.72
7.3.50.0070.00715.00
7.3.40.0000.01314.82
7.3.30.0060.00914.69
7.3.20.0090.00616.55
7.3.10.0070.00716.63
7.3.00.0060.00616.73
7.2.330.0070.01016.77
7.2.320.0100.01016.62
7.2.310.0080.00816.75
7.2.300.0030.01416.95
7.2.290.0120.00916.41
7.2.260.0030.01315.21
7.2.250.0110.00714.71
7.2.240.0060.00914.75
7.2.230.0000.00915.36
7.2.220.0090.00615.10
7.2.210.0070.00715.13
7.2.200.0090.00615.06
7.2.190.0070.01014.83
7.2.180.0080.00314.93
7.2.170.0060.00615.04
7.2.160.0090.00314.99
7.2.150.0140.00316.97
7.2.140.0040.01117.03
7.2.130.0030.01217.04
7.2.120.0030.00916.83
7.2.110.0060.00916.68
7.2.100.0000.01116.70
7.2.90.0200.00915.64
7.2.80.0200.01215.98
7.2.70.0260.01115.92
7.2.60.0200.01216.03
7.2.50.0070.01115.82
7.2.40.0480.01016.02
7.2.30.0230.00815.99
7.2.20.0390.00715.99
7.2.10.0120.01216.12
7.2.00.0080.00816.00
7.1.330.0030.01215.74
7.1.320.0070.00715.64
7.1.310.0030.01015.60
7.1.300.0030.00815.67
7.1.290.0080.00315.59
7.1.280.0030.00615.96
7.1.270.0070.00715.82
7.1.260.0090.00315.71
7.1.250.0030.00615.58
7.1.240.0030.00915.91
7.1.230.0070.00715.86
7.1.220.0000.00815.47
7.1.210.0280.01014.79
7.1.200.0220.00514.77
7.1.190.0190.00514.82
7.1.180.0180.00614.74
7.1.170.0270.00514.59
7.1.160.0280.00614.78
7.1.150.0230.00614.64
7.1.140.0120.00514.75
7.1.130.0180.00814.89
7.1.120.0050.00914.87
7.1.110.0300.00414.68
7.1.100.0230.01114.81
7.1.90.0210.00714.98
7.1.80.0250.00614.74
7.1.70.0140.00914.75
7.1.60.0400.00724.04
7.1.50.0280.00623.94
7.1.40.0700.01323.88
7.1.30.0430.00523.80
7.1.20.0390.00723.61
7.1.10.0190.01314.64
7.1.00.0240.00514.71
7.0.330.0030.00915.25
7.0.320.0090.00615.41
7.0.310.0280.00614.29
7.0.300.0270.00614.38
7.0.290.0180.00714.41
7.0.280.0300.00614.47
7.0.270.0280.00814.32
7.0.260.0270.00514.41
7.0.250.0060.00614.47
7.0.240.0040.01114.55
7.0.230.0220.00614.31
7.0.220.0240.00614.36
7.0.210.0310.00514.56
7.0.200.0120.00514.44
7.0.190.0100.00814.60
7.0.180.0270.00214.40
7.0.170.0290.00814.67
7.0.160.0230.00614.43
7.0.150.0280.00414.44
7.0.140.0200.00914.43
7.0.130.0260.01014.46
7.0.120.0270.00514.44
7.0.110.0240.00414.49
7.0.100.0320.00514.40
7.0.90.0240.00814.55
7.0.80.0240.00714.38
7.0.70.0260.00814.45
7.0.60.0250.00914.56
7.0.50.0290.00814.64
7.0.40.0370.00713.66
7.0.30.0490.00913.49
7.0.20.0350.00713.43
7.0.10.0310.00813.65
7.0.00.0320.00213.55
5.6.400.0090.00314.58
5.6.390.0040.00414.71
5.6.380.0040.00414.39
5.6.370.0050.00514.82
5.6.360.0150.00414.54
5.6.350.0030.01014.61
5.6.340.0130.00014.52
5.6.330.0040.00714.68
5.6.320.0000.01414.61
5.6.310.0040.00714.45
5.6.300.0070.00714.44
5.6.290.0000.01214.74
5.6.280.0080.00814.66
5.6.270.0090.00614.78
5.6.260.0070.00714.61
5.6.250.0060.00314.35
5.6.240.0040.00714.46
5.6.230.0030.01014.60
5.6.220.0030.01014.36
5.6.210.0070.00714.73
5.6.200.0120.00314.70
5.6.190.0070.01014.28
5.6.180.0000.01514.52
5.6.170.0070.00714.44
5.6.160.0080.00414.48
5.6.150.0030.01514.52
5.6.140.0100.00614.33
5.6.130.0000.01514.50
5.6.120.0040.01114.73
5.6.110.0000.01714.50
5.6.100.0070.00714.28
5.6.90.0070.00714.46
5.6.80.0030.00914.47
5.6.70.0060.00614.46
5.6.60.0070.00714.22
5.6.50.0040.00414.26
5.6.40.0120.00614.31
5.6.30.0080.00614.47
5.6.20.0040.01414.43
5.6.10.0030.01514.25
5.6.00.0060.00614.34

preferences:
46.97 ms | 400 KiB | 5 Q