3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // The magic three sequence is the sum of the previous three values minus 1. // // 0,1,1,1,2,3,5, // // assume $n >= 0 function magicThree($n) { $n--; // To an index; $s = array(0,1,1,1); if ($n > 3) { for ($i = 0; $i < $n; $i++) { $s[$i] = $s[$i-1] + $s[$i-2] + $s[$i-3] - 1; } } else { $result = $s[$n]; } print $result; } magicThree(5); ?>

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.3.10.0110.00816.48
7.3.00.0070.01415.76
7.2.130.0140.00716.54
7.2.120.0100.00316.67
7.2.110.0120.00616.28
7.2.100.0100.01016.29
7.2.90.0140.01016.19
7.2.80.0140.01116.14
7.2.70.0140.00716.57
7.2.60.0170.00616.22
7.2.50.0190.01516.66
7.2.40.0120.00916.63
7.2.30.0170.00916.64
7.2.20.0110.01516.37
7.2.10.0180.00716.68
7.2.00.0110.00618.05
7.1.250.0120.00915.23
7.1.100.0080.00318.18
7.1.70.0040.00417.13
7.1.60.0200.00319.46
7.1.50.0030.01916.91
7.1.00.0070.07322.51
7.0.200.0000.00816.95
7.0.140.0000.07721.90
7.0.60.0170.07319.79
7.0.50.0070.06717.88
7.0.40.0070.05720.12
7.0.30.0200.06320.26
7.0.20.0200.04720.17
7.0.10.0070.05320.16
7.0.00.0070.07320.32
5.6.280.0100.06720.93
5.6.210.0100.08320.55
5.6.200.0030.06718.23
5.6.190.0100.05720.56
5.6.180.0530.07320.34
5.6.170.0330.07320.50
5.6.160.0200.07320.50
5.6.150.0000.04018.19
5.6.140.0070.08318.18
5.6.130.0030.04018.14
5.6.120.0100.03721.00
5.6.110.0100.08021.14
5.6.100.0100.07721.11
5.6.90.0170.07721.02
5.6.80.0130.07320.29
5.5.350.0130.03720.35
5.5.340.0070.03717.96
5.5.330.0200.06720.35
5.5.320.0300.07020.32
5.5.310.0330.06320.32
5.5.300.0000.04017.97
5.5.290.0070.08317.95
5.5.280.0030.04720.88
5.5.270.0170.07320.89
5.5.260.0030.06720.89
5.5.250.0030.04020.65
5.5.240.0000.07320.19
5.4.450.0270.06719.20
5.4.440.0900.05319.34
5.4.430.1070.05319.66
5.4.420.1230.06319.52
5.4.410.0630.06719.16
5.4.400.0930.04719.22
5.4.390.0900.06719.12
5.4.380.0100.05718.61
5.4.370.0030.06318.74
5.4.360.0100.05318.79
5.4.350.0130.05318.57
5.4.340.0000.06718.76
5.4.320.0060.03612.51
5.4.310.0070.05112.50
5.4.300.0060.03712.50
5.4.290.0110.05012.50
5.4.280.0070.05212.40
5.4.270.0030.04612.40
5.4.260.0080.03612.40
5.4.250.0050.03812.39
5.4.240.0040.03812.40
5.4.230.0080.03612.39
5.4.220.0060.03712.39
5.4.210.0080.03312.39
5.4.200.0050.03812.39
5.4.190.0060.03612.38
5.4.180.0100.04512.39
5.4.170.0100.03212.40
5.4.160.0070.03612.39
5.4.150.0030.04812.39
5.4.140.0030.04112.07
5.4.130.0060.03412.05
5.4.120.0080.03212.02
5.4.110.0100.03112.01
5.4.100.0080.03312.02
5.4.90.0070.04312.02
5.4.80.0030.04112.02
5.4.70.0070.03412.01
5.4.60.0060.03312.01
5.4.50.0070.03512.01
5.4.40.0060.03512.00
5.4.30.0080.03711.99
5.4.20.0110.03312.00
5.4.10.0100.04211.99
5.4.00.0060.05111.48
5.3.290.0090.03712.80
5.3.280.0090.05012.70
5.3.270.0080.05512.72
5.3.260.0090.04912.72
5.3.250.0140.04012.72
5.3.240.0050.03812.71
5.3.230.0120.03812.71
5.3.220.0090.03512.68
5.3.210.0070.04112.68
5.3.200.0080.03612.68
5.3.190.0070.06712.68
5.3.180.0060.04312.67
5.3.170.0090.04312.67
5.3.160.0080.05212.67
5.3.150.0110.08412.68
5.3.140.0080.07612.66
5.3.130.0070.05112.65
5.3.120.0090.04712.66
5.3.110.0030.05012.66
5.3.100.0080.04012.12
5.3.90.0080.03812.10
5.3.80.0140.05812.09
5.3.70.0040.04312.09
5.3.60.0090.03512.07
5.3.50.0060.05412.02
5.3.40.0090.04612.02
5.3.30.0060.04811.98
5.3.20.0130.03811.76
5.3.10.0180.04211.73
5.3.00.0230.05411.71
5.2.170.0080.0589.21
5.2.160.0090.0329.21
5.2.150.0090.0419.21
5.2.140.0100.0369.20
5.2.130.0050.0339.17
5.2.120.0030.0359.17
5.2.110.0020.0319.18
5.2.100.0080.0339.17
5.2.90.0060.0379.18
5.2.80.0050.0389.17
5.2.70.0060.0329.17
5.2.60.0070.0329.13
5.2.50.0060.0369.09
5.2.40.0070.0379.07
5.2.30.0060.0409.04
5.2.20.0060.0279.04
5.2.10.0040.0288.94
5.2.00.0040.0298.80
5.1.60.0040.0238.08
5.1.50.0060.0368.08
5.1.40.0040.0308.06
5.1.30.0080.0328.41
5.1.20.0080.0278.43
5.1.10.0070.0308.16
5.1.00.0060.0388.16
5.0.50.0050.0246.64
5.0.40.0030.0226.50
5.0.30.0080.0486.31
5.0.20.0030.0256.27
5.0.10.0050.0286.26
5.0.00.0050.0396.25
4.4.90.0050.0214.78
4.4.80.0050.0184.75
4.4.70.0040.0194.76
4.4.60.0000.0194.76
4.4.50.0050.0164.77
4.4.40.0040.0244.71
4.4.30.0010.0204.76
4.4.20.0030.0214.84
4.4.10.0040.0174.85
4.4.00.0050.0314.75
4.3.110.0060.0194.67
4.3.100.0030.0204.67
4.3.90.0020.0184.63
4.3.80.0040.0294.58
4.3.70.0020.0214.63
4.3.60.0050.0164.63
4.3.50.0010.0204.63
4.3.40.0030.0294.54
4.3.30.0040.0173.30
4.3.20.0030.0193.28
4.3.10.0020.0193.24
4.3.00.0100.0177.63