3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.90.0610.00714.85
7.2.80.0440.00714.84
7.2.70.0650.00715.30
7.2.60.0450.00315.23
7.2.50.0170.01015.21
7.2.40.0090.01815.18
7.2.30.0580.00015.03
7.2.20.0470.00315.12
7.2.10.0130.00515.00
7.2.00.0450.00315.38
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
hhvm-3.22.00.0680.18390.74
hhvm-3.21.30.0750.18590.42
hhvm-3.21.00.0970.14590.04
hhvm-3.20.20.0730.16390.15
hhvm-3.19.20.1040.20290.00
hhvm-3.18.50.0650.18588.75
hhvm-3.18.40.0890.15688.67
hhvm-3.15.40.0520.18185.52
5.6.300.0110.00314.27