3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makeGen(array $array = []): Generator { $item = current($array); yield $item; while($item = next($array)) { yield $item; } } class GeneratorIterator implements \Iterator { private $genMaker; private $genArg; private $current; public function __construct(callable $genMaker, $arg) { $this->genMaker = $genMaker; $this->genArg = $arg; $this->current = $genMaker($arg); } public function current() { return $this->current->current(); } public function key() { return $this->current->key(); } public function rewind() { $this->current = call_user_func($this->genMaker, $this->genArg); } public function valid() { return $this->current->valid(); } public function next() { $this->current->next(); } } $genIterator = new GeneratorIterator('makeGen', [1,2,3]); foreach($genIterator as $key => $value) { echo $key . ' -> ' . $value . "\n"; } echo "\n"; foreach($genIterator as $key => $value) { echo $key . ' -> ' . $value . "\n"; }

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.4.130.0100.00817.94
8.4.120.0060.00324.13
8.4.110.0130.00722.69
8.4.100.0100.00818.16
8.4.90.0070.01118.53
8.4.80.0090.01119.52
8.4.70.0050.00417.91
8.4.60.0090.00719.01
8.4.50.0080.00919.52
8.4.40.0130.00717.92
8.4.30.0160.00317.85
8.4.20.0100.01017.71
8.4.10.0100.00719.48
8.3.260.0140.00516.59
8.3.250.0120.00719.04
8.3.240.0090.00716.65
8.3.230.0090.01016.75
8.3.220.0070.00919.02
8.3.210.0110.00716.84
8.3.200.0070.00416.57
8.3.190.0110.00417.27
8.3.180.0080.00116.73
8.3.170.0060.01219.20
8.3.160.0140.00418.51
8.3.150.0080.00019.22
8.3.140.0120.00316.86
8.3.130.0000.00816.73
8.3.120.0000.00820.53
8.3.110.0050.00320.94
8.3.100.0060.00316.57
8.3.90.0090.00918.60
8.3.80.0040.00816.88
8.3.70.0090.00918.43
8.3.60.0070.01116.88
8.3.50.0120.00722.10
8.3.40.0070.00718.96
8.3.30.0130.00318.68
8.3.20.0000.00821.91
8.3.10.0040.00420.54
8.3.00.0040.00420.88
8.2.290.0120.00720.26
8.2.280.0120.00418.41
8.2.270.0120.00619.07
8.2.260.0030.00618.36
8.2.250.0030.00516.70
8.2.240.0040.00418.95
8.2.230.0080.00022.58
8.2.220.0030.01737.54
8.2.210.0030.00526.77
8.2.200.0030.00616.50
8.2.190.0120.00316.58
8.2.180.0100.00616.88
8.2.170.0140.00019.04
8.2.160.0100.00322.96
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00820.63
8.2.110.0060.00322.13
8.2.100.0070.00417.91
8.2.90.0000.00817.83
8.2.80.0030.00619.11
8.2.70.0000.00817.49
8.2.60.0060.00318.04
8.2.50.0000.00818.10
8.2.40.0050.00220.61
8.2.30.0050.00319.25
8.2.20.0030.00518.07
8.2.10.0000.00818.07
8.2.00.0000.00718.27
8.1.330.0100.00921.83
8.1.320.0130.00716.16
8.1.310.0110.00718.28
8.1.300.0080.00017.94
8.1.290.0050.00518.88
8.1.280.0120.00325.92
8.1.270.0040.00424.66
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00617.35
8.1.230.0000.01222.62
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0040.00417.35
8.1.190.0040.00417.35
8.1.180.0030.00518.10
8.1.170.0080.00018.38
8.1.160.0000.00718.84
8.1.150.0040.00420.34
8.1.140.0000.00919.59
8.1.130.0030.00319.08
8.1.120.0040.00417.41
8.1.110.0000.00817.38
8.1.100.0040.00417.50
8.1.90.0100.00017.44
8.1.80.0030.00517.49
8.1.70.0070.00017.51
8.1.60.0030.00517.61
8.1.50.0000.00817.54
8.1.40.0000.00817.46
8.1.30.0040.00417.56
8.1.20.0080.00017.64
8.1.10.0030.00517.63
8.1.00.0040.00417.41
8.0.300.0050.00320.20
8.0.290.0080.00016.75
8.0.280.0030.00318.44
8.0.270.0030.00317.27
8.0.260.0000.00817.30
8.0.250.0030.00316.95
8.0.240.0030.00717.04
8.0.230.0000.00816.90
8.0.220.0030.00316.93
8.0.210.0070.00016.90
8.0.200.0040.00416.92
8.0.190.0070.00016.93
8.0.180.0000.00917.01
8.0.170.0000.00717.02
8.0.160.0050.00216.87
8.0.150.0070.00016.87
8.0.140.0070.00016.95
8.0.130.0030.00413.34
8.0.120.0080.00016.83
8.0.110.0020.00516.86
8.0.100.0040.00416.95
8.0.90.0080.00016.88
8.0.80.0090.00716.95
8.0.70.0050.00317.03
8.0.60.0000.00716.84
8.0.50.0040.00416.82
8.0.30.0100.00817.14
8.0.20.0150.00517.40
8.0.10.0000.00716.87
8.0.00.0060.01216.92
7.4.330.0000.00515.55
7.4.320.0000.00616.64
7.4.300.0000.00616.38
7.4.290.0110.00016.54
7.4.280.0070.00016.54
7.4.270.0030.00316.53
7.4.260.0000.00716.56
7.4.250.0000.00716.63
7.4.240.0030.00316.54
7.4.230.0000.00716.55
7.4.220.0170.01116.63
7.4.210.0060.00916.62
7.4.200.0030.00316.57
7.4.160.0100.00716.44
7.4.150.0400.02017.40
7.4.140.0120.01017.86
7.4.130.0120.00816.61
7.4.120.0100.00916.56
7.4.110.0090.00916.54
7.4.100.0080.01216.40
7.4.90.0060.01216.39
7.4.80.0130.00719.39
7.4.70.0030.01416.54
7.4.60.0090.00916.59
7.4.50.0040.01116.45
7.4.40.0160.00016.49
7.4.30.0090.00616.74
7.4.00.0040.01014.78
7.3.330.0000.00513.37
7.3.320.0000.00513.33
7.3.310.0030.00516.41
7.3.300.0000.00716.31
7.3.290.0040.00416.32
7.3.280.0100.00916.36
7.3.270.0030.01417.40
7.3.260.0150.00316.36
7.3.250.0140.00516.49
7.3.240.0090.00816.48
7.3.230.0100.00716.45
7.3.210.0120.00616.60
7.3.200.0080.01116.64
7.3.190.0040.01216.32
7.3.180.0050.01416.70
7.3.170.0080.00816.52
7.3.160.0090.00816.68
7.2.330.0160.00916.60
7.2.320.0130.00316.86
7.2.310.0120.00616.70
7.2.300.0060.01516.94
7.2.290.0130.01016.58
7.2.60.0080.00816.73
7.2.00.0050.00519.42
7.1.200.0000.01015.91
7.1.100.0060.00618.12
7.1.70.0150.00016.95
7.1.60.0060.01016.88
7.1.50.0190.00316.58
7.1.20.0370.07040.27
7.1.10.0070.06722.15
7.1.00.2570.06720.64
7.0.200.0000.01116.78
7.0.160.0200.06721.88
7.0.150.0100.08721.90
7.0.140.0370.07720.08
7.0.130.0700.06720.00
7.0.120.0770.06019.91
7.0.110.0630.06719.99
7.0.100.0770.05719.98
7.0.90.0030.07022.00
7.0.80.0200.04721.97
7.0.70.0100.05321.70
7.0.60.0100.08021.82
7.0.50.0130.05721.89
7.0.40.0100.06021.83
7.0.30.0030.06321.84
7.0.20.0100.06721.71
7.0.10.0030.06721.82
7.0.00.0100.07321.88

preferences:
28.04 ms | 403 KiB | 5 Q