3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { private $var = array(); public function __construct($array) { if (is_array($array)) { $this->var = $array; } } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->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"; return $var; } public $values = array(1,2,3); public $it = new MyIterator($values); } class MyCollection implements IteratorAggregate { private $items = array(); private $count = 0; // Required definition of interface IteratorAggregate public function getIterator() { return new MyIterator($this->items); } public function add($value) { $this->items[$this->count++] = $value; } } $values = array('value 1','value 2','value 3'); $coll = new MyCollection(); foreach ($coll as $key => $val) { echo "key/value: [$key -> $val]\n\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)
5.4.190.0110.04912.40
5.4.180.0190.03912.40
5.4.170.0180.04212.41
5.4.160.0150.04412.40
5.4.150.0140.04612.40
5.4.140.0110.04612.09
5.4.130.0170.04112.07
5.4.120.0120.04512.04
5.4.110.0160.04112.04
5.4.100.0120.04512.04
5.4.90.0170.04012.03
5.4.80.0140.04312.04
5.4.70.0130.04412.03
5.4.60.0150.04112.04
5.4.50.0140.04212.03
5.4.40.0180.03812.02
5.4.30.0230.06412.01
5.4.20.0100.04512.01
5.4.10.0130.04212.02
5.4.00.0120.04311.51
5.3.270.0160.04412.73
5.3.260.0190.04112.71
5.3.250.0210.06912.72
5.3.240.0180.04112.72
5.3.230.0170.04312.71
5.3.220.0120.04712.68
5.3.210.0140.04612.68
5.3.200.0150.04312.68
5.3.190.0160.04712.67
5.3.180.0200.04212.67
5.3.170.0200.04112.67
5.3.160.0150.04312.68
5.3.150.0130.04612.67
5.3.140.0190.04012.66
5.3.130.0150.04512.66
5.3.120.0160.04412.66
5.3.110.0250.03412.65
5.3.100.0160.04312.13
5.3.90.0140.04312.11
5.3.80.0170.04212.10
5.3.70.0150.04412.10
5.3.60.0150.04412.09
5.3.50.0300.05912.03
5.3.40.0120.04812.03
5.3.30.0150.04412.00
5.3.20.0170.04211.78
5.3.10.0170.04811.74
5.3.00.0160.04711.72

preferences:
141.47 ms | 1386 KiB | 7 Q