3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayMap implements \Iterator { public function __construct(private array $array) { } public function current(): mixed { return current($this->array); } public function next(): void { next($this->array); } public function key(): int|string|null { return key($this->array); } public function valid(): bool { return key($this->array) !== null; } public function rewind(): void { reset($this->array); } } class Aggregate implements \IteratorAggregate { public function __construct(private array $array) { } public function getIterator(): Traversable { return new ArrayMap($this->array); } } class Y { } class Z { } $_1 = new Aggregate([Z::class => Z::class,]); var_dump(1); $_2 = [...iterator_to_array($_1, true)]; var_dump(2); $_3 = [...$_2, Y::class => Z::class]; var_dump(3); $_4 = new Aggregate($_3); var_dump(4); [...$_4]; var_dump(5);

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.5.10.0080.01016.84
8.5.00.0070.01216.50
8.4.160.0120.01022.28
8.4.150.0150.00619.71
8.4.90.0130.00817.79
8.4.70.0400.01017.83
8.3.290.0100.01118.46
8.3.280.0120.00918.31
8.3.180.0120.00718.63
8.3.50.0090.01118.43

preferences:
29.58 ms | 403 KiB | 5 Q