3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {} class Foos implements IteratorAggregate { private function __construct(private readonly Closure $foos) {} public static function fromVariadic(Foo ...$foos): self { return new self(fn() => yield from $foos); } public static function fromGenerator(callable $generator): self { return new self($generator); } public function getIterator(): \Traversable { return ($this->foos)(); } } //$foos = Foos::fromVariadic(new Foo, new Foo); $foos = Foos::fromGenerator(function() { yield new Foo; yield new Foo; }); foreach ($foos as $foo) { var_dump($foo); }

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.140.0050.00316.52
8.3.130.0080.01116.67
8.3.120.0060.00318.99
8.3.110.0000.00822.58
8.3.100.0000.00822.58
8.3.90.0060.01022.58
8.3.50.0030.00622.58
8.2.250.0040.00416.84
8.2.240.0080.00017.23
8.2.230.0050.00222.58
8.2.220.0100.00022.58
8.2.210.0060.00322.58
8.1.300.0070.00416.37
8.1.30.0050.00517.62

preferences:
28.42 ms | 403 KiB | 5 Q