3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace GeneratorExample; class Pipeline { protected $generators = []; function __construct() { foreach (func_get_args() as $g) { $this->add($g); } } function add(callable $generator) { $this->generators[] = $generator; return $this; } function __invoke() { $inputs = func_get_args(); foreach ($this->generators as $g) { $generator = call_user_func_array($g, $inputs); $inputs = [$generator]; } return $generator; } } $uppercase = function(\Traversable $in) { foreach ($in as $word) { yield strtoupper($word); } } $reverse = function(\Traversable $in) { foreach ($in as $word) { yield strrev($word); } } $println = function(\Traversable $in) { foreach ($in as $line) { echo "$line\n"; } } $words = new \ArrayIterator(["foo", "bar", "baz"]); $p = new Pipeline($uppercase, $reverse, $println); $p($words);

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.140.0150.04912.09
5.4.130.0430.04213.14
5.4.120.0150.05112.04
5.4.110.0130.04512.03
5.4.100.0140.05712.03
5.4.90.0160.05812.03
5.4.80.0130.04812.03
5.4.70.0190.05712.03
5.4.60.0150.04912.02
5.4.50.0120.05012.02
5.4.40.0140.04712.01
5.4.30.0200.05112.00
5.4.20.0150.04712.00
5.4.10.0100.04412.00
5.4.00.0110.04311.50
5.3.240.0130.04512.72
5.3.230.0950.04113.22
5.3.220.0180.05712.68
5.3.210.0180.06112.68
5.3.200.0150.05712.68
5.3.190.0170.05812.68
5.3.180.0290.09312.67
5.3.170.0260.08512.67
5.3.160.0150.05112.67
5.3.150.0110.04712.67
5.3.140.0140.05112.66
5.3.130.0130.05712.66
5.3.120.0160.06012.66
5.3.110.0160.05212.66
5.3.100.0140.04512.12
5.3.90.0210.06512.09
5.3.80.0190.06312.08
5.3.70.0160.05012.08
5.3.60.0160.08412.07
5.3.50.0140.05712.02
5.3.40.0160.05912.01
5.3.30.0140.04911.97
5.3.20.0150.04511.75
5.3.10.0220.07111.71
5.3.00.0140.05711.70

preferences:
142.1 ms | 1394 KiB | 7 Q