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.3.30.0170.00922.96
8.3.20.0070.01123.48
8.3.10.0100.01023.65
8.3.00.0130.01322.96
8.2.160.0250.00722.96
8.2.150.0180.00422.96
8.2.140.0080.00822.96
8.2.130.0100.01022.96
8.2.120.0090.01222.96
8.2.110.0190.00322.96
8.2.100.0120.01222.96
8.2.90.0130.00519.55
8.2.80.0120.01222.96
8.2.70.0170.00620.29
8.2.60.0180.00920.29
8.2.50.0170.00520.29
8.2.40.0170.00820.29
8.2.30.0120.00719.27
8.2.20.0080.00519.30
8.2.10.0130.00319.02
8.2.00.0080.00619.06
8.1.270.0090.00624.02
8.1.260.0100.00723.91
8.1.250.0120.00323.71
8.1.240.0240.01222.96
8.1.230.0200.01322.96
8.1.220.0110.01122.96
8.1.210.0170.00622.96
8.1.200.0130.00820.29
8.1.190.0170.00720.29
8.1.180.0200.00520.29
8.1.170.0180.00520.29
8.1.160.0140.00319.14
8.1.150.0090.00518.98
8.1.140.0110.00518.96
8.1.130.0090.00418.53
8.1.120.0060.00518.70
8.1.110.0090.00618.24
8.1.100.0100.00518.22
8.1.90.0100.00518.17
8.1.80.0090.00618.18
8.1.70.0100.00518.19
8.1.60.0120.00518.27
8.1.50.0110.00518.23
8.1.40.0120.00518.29
8.1.30.0120.00518.30
8.1.20.0130.00418.35
8.1.10.0130.00518.26
8.1.00.0120.00518.17
8.0.300.0100.01022.96
8.0.290.0230.00220.29
8.0.280.0120.00618.81
8.0.270.0080.00418.42
8.0.260.0120.00318.27
8.0.250.0090.00417.72
8.0.240.0100.00517.57
8.0.230.0090.00517.58
8.0.220.0100.00417.53
8.0.210.0100.00517.51
8.0.200.0100.00517.58
8.0.190.0100.00517.55
8.0.180.0100.00517.54
8.0.170.0110.00317.57
8.0.160.0090.00517.56
8.0.150.0100.00517.51
8.0.140.0090.00517.50
8.0.130.0100.00417.51
8.0.120.0100.00517.49
8.0.110.0110.00317.50
8.0.100.0100.00417.49
8.0.90.0090.00517.51
8.0.80.0100.00417.50
8.0.70.0090.00517.50
8.0.60.0100.00517.51
8.0.50.0100.00417.50
8.0.30.0100.00417.52
8.0.20.0090.00517.54
8.0.10.0090.00517.56
7.4.330.0080.00414.84
7.4.320.0100.00517.08
7.4.300.0110.00417.09
7.4.290.0110.00517.09
7.4.280.0110.00517.14
7.4.270.0120.00417.15
7.4.260.0110.00417.12
7.4.250.0110.00517.06
7.4.240.0110.00417.07
7.4.230.0110.00417.12
7.4.220.0090.00517.08
7.4.210.0100.00417.07
7.4.200.0090.00517.08
7.4.190.0090.00517.19
7.4.180.0080.00417.18
7.4.160.0090.00417.23
7.4.150.0090.00417.08
7.4.140.0080.00517.08
7.4.130.0090.00416.97
7.4.120.0080.00517.01
7.4.110.0080.00417.11
7.4.100.0090.00417.16
7.4.90.0080.00517.00
7.4.80.0090.00317.15
7.4.70.0070.00517.10
7.4.60.0070.00416.97
7.4.50.0070.00517.01
7.4.40.0080.00416.91
7.4.30.0080.00417.04
7.4.20.0070.00417.26
7.4.10.0070.00417.29
7.4.00.0080.00317.23

preferences:
155.7 ms | 939 KiB | 8 Q