3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { private $whatever = false; public function __construct() { $a = iterator_to_array($this->firstIterator()); $b = iterator_to_array($this->secondIterator($this->firstIterator())); $c = iterator_to_array($this->thirdIterator($this->firstIterator())); $this->whatever = true; $d = iterator_to_array($this->firstIterator()); $e = iterator_to_array($this->secondIterator($this->firstIterator())); $f = iterator_to_array($this->thirdIterator($this->firstIterator())); var_dump([$a, $b, $c, $d, $e, $f]); } public function firstIterator(): \Iterator { yield 'a'=> 1; yield 'b'=> 2; yield 'c'=> 3; } public function secondIterator(\Iterator $first): \Iterator { if ($this->whatever === true) { return $first; } foreach($first as $key=>$value) { yield $key => $value * $value; } } public function thirdIterator(\Iterator $first): \Iterator { if ($this->whatever === true) { return $first; } return $this->thirdSubIterator($first); } public function thirdSubIterator(\Iterator $first): \Iterator { foreach($first as $key=>$value) { yield $key => $value * $value; } } } new test();

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.70.0070.01116.58
8.3.60.0090.00616.61
8.3.50.0070.01020.05
8.3.40.0170.00318.62
8.3.30.0070.00718.84
8.3.20.0030.00624.18
8.3.10.0050.00324.66
8.3.00.0100.00026.16
8.2.180.0140.00325.92
8.2.170.0140.00719.14
8.2.160.0030.01222.96
8.2.150.0040.00425.66
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00026.35
8.2.110.0090.00021.09
8.2.100.0080.00417.91
8.2.90.0060.00318.03
8.2.80.0030.00518.05
8.2.70.0030.00518.05
8.2.60.0030.00618.09
8.2.50.0040.00418.10
8.2.40.0070.00319.34
8.2.30.0000.00819.26
8.2.20.0050.00218.14
8.2.10.0040.00419.27
8.2.00.0040.00419.14
8.1.280.0130.00925.92
8.1.270.0030.01623.80
8.1.260.0070.00028.09
8.1.250.0000.00828.09
8.1.240.0090.00317.45
8.1.230.0080.00422.71
8.1.220.0000.00817.74
8.1.210.0050.00318.97
8.1.200.0030.00617.35
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0030.00618.66
8.1.160.0050.00319.03
8.1.150.0040.00418.89
8.1.140.0000.00718.91
8.1.130.0070.00020.10
8.1.120.0050.00317.52
8.1.110.0070.00017.33
8.1.100.0030.00517.48
8.1.90.0070.00317.46
8.1.80.0040.00817.42
8.1.70.0020.00517.36
8.1.60.0040.00417.49
8.1.50.0040.00417.49
8.1.40.0000.00817.57
8.1.30.0040.00417.67
8.1.20.0030.00517.71
8.1.10.0040.00717.46
8.1.00.0090.00017.49
8.0.300.0070.00019.77
8.0.290.0050.00516.75
8.0.280.0000.00718.43
8.0.270.0000.00716.78
8.0.260.0030.00318.47
8.0.250.0070.00017.05
8.0.240.0040.00417.01
8.0.230.0030.00316.98
8.0.220.0000.00816.84
8.0.210.0030.00316.99
8.0.200.0040.00417.13
8.0.190.0040.00417.03
8.0.180.0080.00017.00
8.0.170.0040.00417.02
8.0.160.0030.00616.93
8.0.150.0070.00016.92
8.0.140.0040.00416.86
8.0.130.0030.00613.41
8.0.120.0040.00416.83
8.0.110.0050.00316.93
8.0.100.0080.00016.88
8.0.90.0030.00416.84
8.0.80.0070.00717.00
8.0.70.0040.00416.82
8.0.60.0020.00517.09
8.0.50.0080.00017.04
8.0.30.0080.01117.24
8.0.20.0130.00717.24
8.0.10.0050.00316.97
8.0.00.0090.01516.76
7.4.330.0000.00515.55
7.4.320.0040.00416.45
7.4.300.0030.00316.52
7.4.290.0000.00816.46
7.4.280.0000.00816.51
7.4.270.0000.00716.57
7.4.260.0000.00613.22
7.4.250.0040.00416.48
7.4.240.0050.00216.52
7.4.230.0030.00416.64
7.4.220.0050.00216.48
7.4.210.0050.01016.52
7.4.200.0000.00716.59
7.4.130.0080.01316.42
7.4.120.0090.01016.58
7.4.110.0080.01216.55
7.4.100.0100.01016.43
7.4.90.0120.00916.23
7.4.80.0180.00016.49
7.4.70.0120.00616.22
7.4.60.0100.00716.48
7.4.50.0120.00916.31
7.4.40.0120.00616.27
7.4.30.0120.00616.19
7.4.20.0060.01216.29
7.4.10.0120.00616.50
7.4.00.0110.00716.49
7.3.330.0030.00316.25
7.3.320.0030.00313.23
7.3.310.0070.00016.38
7.3.300.0070.00016.23
7.3.290.0090.00816.38
7.3.280.0060.01116.30
7.3.260.0180.00016.43
7.3.230.0100.00616.53
7.3.210.0070.01416.19
7.3.200.0070.01016.27
7.3.190.0150.00316.27
7.3.180.0070.01416.59
7.3.170.0070.01416.35
7.3.160.0100.00716.57
7.3.150.0090.00916.32
7.3.140.0090.01216.61
7.3.130.0090.01016.34
7.3.120.0090.00916.41
7.3.110.0120.00616.26
7.3.100.0040.01316.46
7.3.90.0090.00916.32
7.3.80.0060.01216.21
7.3.70.0130.00516.29
7.3.60.0090.00916.42
7.3.50.0110.00616.28
7.3.40.0030.01416.19
7.3.30.0030.01916.30
7.3.20.0170.00716.41
7.3.10.0090.00916.30
7.3.00.0130.00916.29
7.2.330.0130.00416.63
7.2.320.0060.01216.54
7.2.310.0070.01316.37
7.2.300.0150.00316.33
7.2.290.0110.00816.55
7.2.280.0120.00916.45
7.2.270.0120.00916.73
7.2.260.0050.01416.41
7.2.250.0180.00316.77
7.2.240.0180.00316.50
7.2.230.0200.00316.75
7.2.220.0090.00916.78
7.2.210.0110.00716.46
7.2.200.0140.00616.52
7.2.190.0100.01016.68
7.2.180.0070.01116.59
7.2.170.0110.00816.64
7.2.160.0120.00616.70
7.2.150.0070.01116.66
7.2.140.0110.00816.57
7.2.130.0070.01116.57
7.2.120.0100.01416.63
7.2.110.0280.00916.50
7.2.100.0130.00716.79
7.2.90.0110.00816.58
7.2.80.0200.00316.55
7.2.70.0070.01116.80
7.2.60.0150.00616.59
7.2.50.0130.00916.59
7.2.40.0140.00516.62
7.2.30.0030.01816.77
7.2.20.0130.00816.82
7.2.10.0140.00716.48
7.2.00.0140.01016.46

preferences:
59.58 ms | 401 KiB | 5 Q