3v4l.org

run code in 300+ PHP versions simultaneously
<?php lass MapIterator implements Iterator { private $f; private $inner; public function __construct($f, $inner) { $this->f = $f; $this->inner = $inner; } function rewind() { return $this->inner->rewind(); } function current() { return call_user_func($this->f, $this->inner->current()); } function key() { return $this->inner->key(); } function next() { return $this->inner->next(); } function valid() { return $this->inner->valid(); } } function iter_map($f, $iter) { return new MapIterator($f, $iter); } // example: function times_two($x) { return $x * 2; } $source = new ArrayIterator([0, 1, 2, 3, 4, 5, 6]); //var_dump(iterator_to_array(iter_map('times_two', $source))); print_r(iterator_to_array(gen_map('times_two', $source)));

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.220.0120.04212.37
5.4.210.0140.03812.37
5.4.200.0130.04312.37
5.4.190.0120.04312.37
5.4.180.0130.04112.37
5.4.170.0110.04312.38
5.4.160.0160.04212.37
5.4.150.0120.04312.37
5.4.140.0180.05712.06
5.4.130.0130.04212.04
5.4.120.0130.03912.01
5.4.110.0230.06112.00
5.4.100.0110.04312.00
5.4.90.0120.04312.00
5.4.80.0120.04512.01
5.4.70.0100.04712.00
5.4.60.0110.04712.00
5.4.50.0170.05812.00
5.4.40.0120.04811.99
5.4.30.0100.04511.98
5.4.20.0110.04511.98
5.4.10.0130.04611.98
5.4.00.0130.04611.47
5.3.270.0210.05612.72
5.3.260.0150.04612.72
5.3.250.0230.07412.72
5.3.240.0140.04612.72
5.3.230.0120.04712.71
5.3.220.0110.04912.68
5.3.210.0180.05212.68
5.3.200.0120.04912.68
5.3.190.0120.04912.68
5.3.180.0140.04912.67
5.3.170.0140.04712.67
5.3.160.0120.04912.67
5.3.150.0120.04712.67
5.3.140.0130.04512.66
5.3.130.0120.04712.65
5.3.120.0210.06512.66
5.3.110.0130.04312.66
5.3.100.0120.04112.12
5.3.90.0140.03812.08
5.3.80.0120.03912.07
5.3.70.0140.04212.07
5.3.60.0170.05212.06
5.3.50.0110.04212.00
5.3.40.0140.03812.00
5.3.30.0120.04011.94
5.3.20.0100.04311.72
5.3.10.0110.03811.68
5.3.00.0110.04011.67

preferences:
139.32 ms | 1394 KiB | 7 Q