3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen1($a = 0) { $i = 0; while($i < 5) { yield $a; $a = $a + 1; $i = $i + 1; } return $a * 5; } function yf() { $bs = yield from []; echo "Done with the garbage iterator. Should return nothing. Actual return value below:\n"; var_dump($bs); $som = yield from [1, 2, 3]; echo "Done with the iterator. Result was $som\n"; $res = yield from gen1(); echo "Done with the first generator. Result was $res\n"; $oth = yield from gen1($res); echo "Done with the second generator. Result was $oth\n"; return $oth; } $g = yf(); foreach($g as $val) { var_dump($val); } var_dump($g->getReturn());

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0110.00416.64
7.2.00.0040.00819.24
7.1.200.0000.01415.69
7.1.100.0030.01018.06
7.1.70.0080.00017.26
7.1.60.0110.01419.48
7.1.50.0110.01416.78
7.1.00.0070.07022.35
7.0.200.0270.00914.66
7.0.60.0200.07319.85
7.0.50.0070.04717.93
7.0.40.0030.08020.02
7.0.30.0030.05020.29
7.0.20.0200.04720.20
7.0.10.0130.08020.25
7.0.00.0070.06720.12
5.6.280.0000.03321.02
5.6.210.0070.05720.57
5.6.200.0100.07018.24
5.6.190.0130.05720.34
5.6.180.0330.07020.35
5.6.170.0300.07720.51
5.6.160.0170.04720.55
5.6.150.0000.09018.15
5.6.140.0170.07318.23
5.6.130.0130.04318.14
5.6.120.0100.08321.04
5.6.110.0200.05320.89
5.6.100.0130.07720.89
5.6.90.0200.07021.00
5.6.80.0030.04020.54
5.5.350.0170.05720.43
5.5.340.0000.08017.95
5.5.330.0030.05020.21
5.5.320.0270.05020.26
5.5.310.0300.07320.37
5.5.300.0000.04017.95
5.5.290.0070.04317.95
5.5.280.0070.08020.74
5.5.270.0170.07020.87
5.5.260.0130.07020.98
5.5.250.0070.08320.61
5.5.240.0170.03020.27
5.4.450.0800.04719.46
5.4.440.0700.05319.58
5.4.430.0670.05319.68
5.4.420.0670.05719.30
5.4.410.0670.05319.47
5.4.400.0730.04719.16
5.4.390.0700.05318.98
5.4.380.0800.04018.85
5.4.370.0670.05318.87
5.4.360.0730.05719.26
5.4.350.0730.05019.26
5.4.340.0630.06018.87
5.4.320.0730.05319.01
5.4.310.0700.05019.23
5.4.300.0670.04719.22
5.4.290.0700.04719.13
5.4.280.0830.06019.25
5.4.270.0630.05319.28
5.4.260.0630.05019.26
5.4.250.0700.05319.05
5.4.240.0670.06319.00
5.4.230.0770.05719.25
5.4.220.0730.05719.14
5.4.210.0730.05319.28
5.4.200.0730.04719.22
5.4.190.0700.04019.14
5.4.180.0530.05719.12
5.4.170.0600.05318.96
5.4.160.0630.05018.84
5.4.150.0570.06019.34
5.4.140.0530.05716.43
5.4.130.0700.05016.51
5.4.120.0730.04316.50
5.4.110.0800.04016.51
5.4.100.0770.04316.60
5.4.90.0770.04316.41
5.4.80.0670.05016.59
5.4.70.0700.04716.51
5.4.60.0670.05016.52
5.4.50.0870.03316.36
5.4.40.0700.05016.24
5.4.30.0730.04316.57
5.4.20.0770.05016.57
5.4.10.0600.05016.59
5.4.00.0670.04015.75
5.3.290.0600.05314.71
5.3.280.0600.05714.67
5.3.270.0600.05014.61
5.3.260.0530.06014.65
5.3.250.0600.05014.59
5.3.240.0730.05014.61
5.3.230.0700.05014.50
5.3.220.0730.05014.73
5.3.210.0730.05014.62
5.3.200.0630.05714.48
5.3.190.0770.04314.54