3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; echo "Sup!\n"; $y = yield 2; var_dump($x + $y); } function yfgenerator() { yield from gen1(); echo "Dawg\n"; yield from gen1(); } function yfeiterator() { $arr = [1, 2, 3]; foreach($arr as $val) { yield $val; } } function yfiterator() { yield from []; yield from [1, 2, 3]; /**/ yield from array( "first" => 1, "second" => 2, "third" => 3, ); /**/ } function iterationTest($g) { echo "About to start iteration\n"; foreach($g as $key => $val) { echo "Iteration!\n"; var_dump($key); var_dump($val); } echo "Done with iteration\n"; } function sendingTest($g) { $g->send(10); var_dump($g->current()); $g->send(20); var_dump($g->current()); } //iterationTest(yfiterator()); // iterationTest(gen1()); sendingTest(yfiterator()); echo "======\n"; sendingTest(yfgenerator()); echo "Done with all tests\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.3.70.0180.00318.20
8.3.60.0110.00416.75
8.3.50.0120.01022.09
8.3.40.0070.00718.66
8.3.30.0100.01018.71
8.3.20.0040.00420.25
8.3.10.0080.00021.90
8.3.00.0060.00319.26
8.2.180.0090.00916.35
8.2.170.0070.00722.96
8.2.160.0040.01120.52
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0000.00826.16
8.2.120.0000.00817.50
8.2.110.0110.00022.16
8.2.100.0090.00318.04
8.2.90.0050.00319.22
8.2.80.0000.00817.97
8.2.70.0050.00317.47
8.2.60.0030.00618.03
8.2.50.0000.00818.07
8.2.40.0090.00021.15
8.2.30.0040.00420.58
8.2.20.0000.00817.75
8.2.10.0000.00717.94
8.2.00.0000.00818.05
8.1.280.0030.01725.92
8.1.270.0040.00423.84
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0040.00422.60
8.1.230.0070.00417.66
8.1.220.0050.00317.74
8.1.210.0030.00718.77
8.1.200.0060.00317.35
8.1.190.0080.00017.22
8.1.180.0050.00318.10
8.1.170.0060.00320.29
8.1.160.0040.00422.06
8.1.150.0040.00418.90
8.1.140.0000.00819.46
8.1.130.0040.00417.76
8.1.120.0040.00417.37
8.1.110.0040.00417.31
8.1.100.0050.00317.47
8.1.90.0040.00417.42
8.1.80.0040.00417.46
8.1.70.0030.00517.37
8.1.60.0030.00517.63
8.1.50.0030.00617.55
8.1.40.0080.00017.41
8.1.30.0040.00417.60
8.1.20.0020.00517.69
8.1.10.0000.00817.53
8.1.00.0080.00017.38
8.0.300.0000.00918.77
8.0.290.0070.00016.75
8.0.280.0000.00818.45
8.0.270.0000.00916.99
8.0.260.0060.00017.27
8.0.250.0040.00416.86
8.0.240.0040.00417.03
8.0.230.0000.00916.93
8.0.220.0030.00316.77
8.0.210.0040.00416.94
8.0.200.0030.00316.91
8.0.190.0050.00216.95
8.0.180.0080.00016.92
8.0.170.0070.00016.92
8.0.160.0070.00016.94
8.0.150.0040.00416.82
8.0.140.0040.00416.77
8.0.130.0000.00813.37
8.0.120.0040.00416.92
8.0.110.0040.00416.81
8.0.100.0000.00716.92
8.0.90.0030.00516.93
8.0.80.0100.00616.88
8.0.70.0000.00816.73
8.0.60.0000.00816.73
8.0.50.0020.00516.79
8.0.30.0120.00717.30
8.0.20.0110.00917.40
8.0.10.0000.00717.02
8.0.00.0100.00816.76
7.4.330.0050.00015.08
7.4.320.0030.00316.44
7.4.300.0000.00616.62
7.4.290.0030.00316.51
7.4.280.0070.00016.60
7.4.270.0000.00716.59
7.4.260.0070.00016.46
7.4.250.0040.00416.47
7.4.240.0050.00216.49
7.4.230.0070.00016.69
7.4.220.0140.01116.55
7.4.210.0030.01016.64
7.4.200.0040.00416.60
7.4.160.0070.00716.50
7.4.150.0030.01517.40
7.4.140.0100.01317.86
7.4.130.0110.01316.49
7.4.120.0090.01516.50
7.4.110.0030.01916.52
7.4.100.0080.01016.41
7.4.90.0130.00316.61
7.4.80.0100.00719.39
7.4.70.0110.00616.57
7.4.60.0100.00716.57
7.4.50.0000.00816.39
7.4.40.0040.01216.61
7.4.30.0090.01216.25
7.4.00.0120.00414.93
7.3.330.0030.00313.24
7.3.320.0000.00513.26
7.3.310.0000.00816.27
7.3.300.0070.00016.28
7.3.290.0070.00916.28
7.3.280.0110.00516.30
7.3.270.0140.00317.40
7.3.260.0140.00316.41
7.3.240.0080.00916.54
7.3.230.0070.01316.52
7.3.210.0070.01016.27
7.3.200.0130.00416.26
7.3.190.0150.00316.59
7.3.180.0130.00316.43
7.3.170.0140.00716.35
7.3.160.0130.00316.24
7.3.120.0130.00315.12
7.3.110.0030.01615.07
7.3.100.0040.00814.89
7.3.90.0100.00714.79
7.3.80.0000.01014.77
7.3.70.0000.01714.50
7.3.60.0040.00714.88
7.3.50.0060.00714.59
7.3.40.0040.01114.73
7.3.30.0060.00914.68
7.3.20.0090.00616.68
7.3.10.0140.00016.63
7.3.00.0000.00916.69
7.2.330.0120.00616.86
7.2.320.0150.00316.88
7.2.310.0070.01016.61
7.2.300.0070.01016.73
7.2.290.0120.00616.63
7.2.250.0080.01114.83
7.2.240.0060.00914.80
7.2.230.0090.00914.98
7.2.220.0040.01215.03
7.2.210.0000.01315.00
7.2.200.0070.01015.05
7.2.190.0040.00815.21
7.2.180.0100.00314.88
7.2.170.0040.01215.14
7.2.110.0180.00416.52
7.2.60.0070.00716.61
7.2.00.0000.01319.32
7.1.330.0030.01015.57
7.1.320.0100.00615.53
7.1.310.0070.00715.48
7.1.300.0000.01015.60
7.1.290.0000.01515.46
7.1.280.0030.00915.66
7.1.270.0030.01315.45
7.1.260.0100.00715.66
7.1.200.0050.00315.68
7.1.100.0040.01118.11
7.1.70.0030.00616.95
7.1.60.0140.01119.13
7.1.50.0090.01316.64
7.1.00.0070.07322.28
7.0.200.0050.00514.97
7.0.60.0070.07319.93
7.0.50.0070.08017.88
7.0.40.0170.07320.14
7.0.30.0330.07320.11
7.0.20.0170.06020.23
7.0.10.0330.06020.21
7.0.00.0030.04320.09
5.6.280.0070.07321.04
5.6.210.0070.06020.63
5.6.200.0170.07018.21
5.6.190.0030.04320.66
5.6.180.0000.06320.34
5.6.170.0270.04020.52
5.6.160.0030.09020.50
5.6.150.0030.04318.15
5.6.140.0000.06318.21
5.6.130.0070.08718.28
5.6.120.0100.04721.05
5.6.110.0130.07321.12
5.6.100.0100.08321.00
5.6.90.0030.04721.09
5.6.80.0070.05720.54
5.6.70.0170.03720.40
5.5.350.0100.04720.41
5.5.340.0130.07718.01
5.5.330.0070.04020.41
5.5.320.0070.08020.35
5.5.310.0170.05320.24
5.5.300.0070.08017.96
5.5.290.0100.08318.08
5.5.280.0100.04020.75
5.5.270.0100.03720.76
5.5.260.0170.06320.89
5.5.250.0130.07720.68
5.5.240.0030.07020.35
5.4.450.0300.04719.70
5.4.440.0100.06019.34
5.4.430.0130.05319.64
5.4.420.0130.05719.56
5.4.410.0130.05319.57
5.4.400.0130.05019.13
5.4.390.0100.05318.85
5.4.380.0070.05719.15
5.4.370.0100.05319.11
5.4.360.0100.05319.13
5.4.350.0130.05319.13
5.4.340.0100.05719.31
5.4.320.0130.05319.23
5.4.310.0070.05719.14
5.4.300.0030.06019.14
5.4.290.0200.04319.12
5.4.280.0100.05318.96
5.4.270.0100.05319.27
5.4.260.0030.06019.23
5.4.250.0100.05318.84
5.4.240.0100.05718.86
5.4.230.0170.05018.86
5.4.220.0230.04319.12
5.4.210.0270.03719.00
5.4.200.0200.04318.84
5.4.190.0170.05018.95
5.4.180.0070.06319.13
5.4.170.0130.05319.05
5.4.160.0130.05018.94
5.4.150.0170.05018.96
5.4.140.0130.05016.55
5.4.130.0170.04316.57
5.4.120.0130.04716.48
5.4.110.0000.06316.62
5.4.100.0100.05316.28
5.4.90.0130.05016.42
5.4.80.0100.05016.24
5.4.70.0130.05316.58
5.4.60.0170.04716.40
5.4.50.0030.05716.59
5.4.40.0070.05316.55
5.4.30.0100.05316.59
5.4.20.0070.05316.61
5.4.10.0170.04316.62
5.4.00.0100.06715.86

preferences:
42.07 ms | 401 KiB | 5 Q