3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @template TKey * @template TValue * @implements IteratorAggregate<TKey, TValue> */ final class RewindableGenerator implements IteratorAggregate { /** * @param callable(): Generator<TKey, TValue> $generatorFunction */ public function __construct(private $generatorFunction) {} public function getIterator(): Traversable { return ($this->generatorFunction)(); } } /** * @return Generator<int, int> */ function thousand(): Generator { for ($i = 0; $i < 1000; ++$i) { yield $i; } } $thousand = new RewindableGenerator(thousand(...)); foreach ($thousand as $i); foreach ($thousand as $i); foreach ($thousand as $i);

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.2rc30.0060.00418.62
8.2rc20.0090.00518.57
8.2rc10.0090.00518.18
8.1.130.0050.00418.36
8.1.120.0060.00518.71
8.1.110.0090.00618.12
8.1.100.0100.00518.08
8.1.90.0100.00518.02
8.1.80.0090.00618.03
8.1.70.0100.00518.05
8.1.60.0110.00518.14
8.1.50.0110.00518.09
8.1.40.0120.00418.15
8.1.30.0130.00518.16
8.1.20.0130.00418.23
8.1.10.0130.00518.12
8.1.00.0120.00518.02
8.0.250.0090.00517.57
8.0.240.0090.00617.35
8.0.230.0100.00517.35
8.0.220.0100.00517.29
8.0.210.0100.00517.27
8.0.200.0100.00517.35
8.0.190.0090.00517.33
8.0.180.0110.00417.32
8.0.170.0110.00417.35
8.0.160.0090.00617.34
8.0.150.0090.00517.28
8.0.140.0090.00517.27
8.0.130.0100.00417.28
8.0.120.0100.00517.26
8.0.110.0110.00317.27
8.0.100.0100.00417.26
8.0.90.0090.00517.26
8.0.80.0100.00417.27
8.0.70.0100.00517.25
8.0.60.0100.00517.27
8.0.50.0100.00417.26
8.0.30.0100.00417.29
8.0.20.0090.00517.32
8.0.10.0090.00517.33
7.4.330.0070.00413.97
7.4.320.0090.00416.79
7.4.300.0110.00416.79
7.4.290.0100.00416.79
7.4.280.0100.00516.85
7.4.270.0120.00416.87
7.4.260.0100.00416.80
7.4.250.0110.00416.76
7.4.240.0100.00416.76
7.4.230.0100.00416.83
7.4.220.0090.00516.77
7.4.210.0090.00416.77
7.4.200.0080.00516.79
7.4.190.0080.00516.91
7.4.180.0080.00416.90
7.4.160.0080.00316.97
7.4.150.0080.00416.78
7.4.140.0070.00516.79
7.4.130.0080.00416.66
7.4.120.0070.00516.70
7.4.110.0080.00416.83
7.4.100.0080.00416.89
7.4.90.0060.00516.68
7.4.80.0080.00316.89
7.4.70.0060.00516.82
7.4.60.0060.00416.64
7.4.50.0050.00416.72
7.4.40.0060.00416.59
7.4.30.0060.00416.75
7.4.20.0060.00417.02
7.4.10.0060.00417.06
7.4.00.0070.00316.99

preferences:
13.75 ms | 406 KiB | 5 Q