3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_1($nb) { $t = microtime(true); $a = 'f'; $t = microtime(true); $b = ''; $t = microtime(true); for ($u=0; $u<$nb; $u++) { if ($a==='a') { $b .= $a; } else if ($a==='b') { $b .= $a; } else if ($a==='c') { $b .= $a; } else if ($a==='d') { $b .= $a; } else if ($a==='e') { $b .= $a; } else if ($a==='f') { $b .= $a; } } return (microtime(true) - $t); } function test_2($nb) { $a = 'f'; $b = ''; $t = microtime(true); for ($u=0; $u<$nb; $u++) { switch ($a) { case 'a': $b .= $a; case 'b': $b .= $a; case 'c': $b .= $a; case 'd': $b .= $a; case 'e': $b .= $a; case 'f': $b .= $a; } } return (microtime(true) - $t); } $nb = 10000000; echo 'test_1: '.test_1($nb)."\n"; echo 'test_2: '.test_2($nb)."\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)
7.1.70.0101.56931.21
7.1.60.0201.68631.09
7.1.50.0131.38030.81
7.1.40.0131.44530.79
7.1.30.0231.49430.74
7.1.20.0131.52930.68
7.1.10.0031.39830.77
7.1.00.0631.41030.59
7.0.200.0101.45230.84
7.0.190.0101.35430.83
7.0.180.0131.37330.30
7.0.170.0171.52930.43
7.0.160.0131.36830.38
7.0.150.0031.41330.33
7.0.140.0171.42530.46
7.0.130.0301.40130.89
7.0.120.0031.44330.54
7.0.110.0331.60130.62
7.0.100.0301.48830.48
7.0.90.0401.42630.13
7.0.80.0171.68930.23
7.0.70.0201.49630.57
7.0.60.0031.35930.23
7.0.50.0201.52230.39
7.0.40.0131.41926.22
7.0.30.0261.56326.39
7.0.20.0171.36726.27
7.0.10.0101.49726.40
7.0.00.0201.74026.44
5.6.300.0302.474129.00
5.6.290.0172.487121.78
5.6.280.0232.480101.36
5.6.270.0202.484115.05
5.6.260.0132.48830.14
5.6.250.0172.18130.15
5.6.240.0232.15368.13
5.6.230.0102.17530.24
5.6.220.0102.16130.11
5.6.210.0102.39830.31
5.6.200.0102.08930.25
5.6.190.0102.21930.08
5.6.180.0102.11930.25
5.6.170.0032.11029.91
5.6.160.0172.20829.96
5.6.150.0072.08029.93
5.6.140.0172.16230.16
5.6.130.0232.23030.16
5.6.120.0102.20930.13
5.6.110.0202.22729.95
5.6.100.0132.25830.02
5.6.90.0172.13730.13
5.6.80.0171.59929.65
5.6.70.0272.20029.73
5.6.60.0072.10929.73
5.6.50.0602.16329.54
5.6.40.1601.37329.62
5.6.30.0132.19429.52
5.6.20.0172.18829.51
5.6.10.0102.02429.52
5.6.00.0201.98729.44
5.5.380.0202.35426.88
5.5.370.0202.32026.86
5.5.360.0202.36026.88
5.5.350.0172.25826.80
5.5.340.0102.38827.01
5.5.330.0032.48726.98
5.5.320.0172.44427.30
5.5.310.0072.46627.26
5.5.300.0102.45427.32
5.5.290.0132.47127.16
5.5.280.0102.45026.93
5.5.270.0072.46227.13
5.5.260.0172.46327.27
5.5.250.0172.46627.07
5.5.240.0102.46326.77
5.5.230.0072.46426.76
5.5.220.0132.45626.54
5.5.210.0172.45526.36
5.5.200.0232.44526.75
5.5.190.0102.45626.77
5.5.180.0072.46026.50
5.5.160.0132.45526.62
5.5.150.0172.44626.67
5.5.140.0172.45326.49
5.5.130.0232.44926.32
5.5.120.0072.44326.67
5.5.110.0102.45126.50
5.5.100.0072.46626.38
5.5.90.0032.47826.55
5.5.80.0072.45426.52
5.5.70.0102.46226.47
5.5.60.0132.34126.57
5.5.50.0132.45026.39
5.5.40.0272.44326.23
5.5.30.0202.44026.22
5.5.20.0132.44626.61
5.5.10.0102.44526.63
5.5.00.0172.43326.62
5.4.450.0172.44728.41
5.4.440.0072.43628.63
5.4.430.0002.45428.50
5.4.420.0202.46028.75
5.4.410.0132.38028.62
5.4.400.0332.426113.44
5.4.390.0132.45328.22
5.4.380.0132.45528.39
5.4.370.0032.47128.09
5.4.360.0132.47728.34
5.4.350.0172.45228.23
5.4.340.0172.40528.37
5.4.320.0132.42928.50
5.4.310.0172.45428.35
5.4.300.0232.42728.50
5.4.290.0132.47628.45
5.4.280.0132.46028.11
5.4.270.0002.49028.24
5.4.260.0202.44528.20
5.4.250.0132.47028.38
5.4.240.0132.44928.23
5.4.230.0132.44228.28
5.4.220.0302.39428.38
5.4.210.0072.40828.49
5.4.200.0102.46828.25
5.4.190.0032.32728.45
5.4.180.0102.47328.23
5.4.170.0132.42828.34
5.4.160.0172.44928.20
5.4.150.0102.48128.19
5.4.140.0132.34225.81
5.4.130.0072.47626.01
5.4.120.0102.45825.84
5.4.110.0172.44725.81
5.4.100.0132.43325.72
5.4.90.0102.38226.01
5.4.80.0072.47025.75
5.4.70.0032.46426.03
5.4.60.0102.45825.93
5.4.50.0132.44425.86
5.4.40.0072.47325.82
5.4.30.0202.44725.69
5.4.20.0132.44125.66
5.4.10.0172.43225.80
5.4.00.0172.41025.48
5.3.290.0032.42124.25
5.3.280.0072.48324.13
5.3.270.0102.35724.50
5.3.260.0102.46624.48
5.3.250.0132.45824.42
5.3.240.0132.44124.25
5.3.230.0172.43324.44
5.3.220.0102.45824.21
5.3.210.0072.46024.02
5.3.200.0102.47824.37
5.3.190.0072.46024.35
5.3.180.0072.45824.34
5.3.170.0032.47124.20
5.3.160.0302.43624.35
5.3.150.0032.46624.20
5.3.140.0072.45624.33
5.3.130.1272.34724.33
5.3.120.0072.45724.39
5.3.110.0132.42224.19
5.3.100.0132.44323.82
5.3.90.0002.45823.89
5.3.80.0072.45823.55
5.3.70.0072.45723.81
5.3.60.0132.45623.39
5.3.50.0102.45423.75
5.3.40.0132.46123.73
5.3.30.0032.47423.70
5.3.20.0132.42923.23
5.3.10.0032.46523.39
5.3.00.0032.46023.43

preferences:
51.77 ms | 400 KiB | 5 Q