3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = range(1,100000); //100k items, ordered. function searchInArray(array $haystack, $needle) { $needle = (int)$needle; $currPos = (int)(count($haystack) / 2); $topBoundry = count($haystack); $bottomBoundry = 0; $moves = 0; while ($currPos >= $bottomBoundry && $currPos <= $topBoundry) { $currItem = $haystack[$currPos]; if ($currItem == $needle) { echo "Found item in $moves moves!"; return $currPos; } else if ($currItem < $needle) { $currPos -= floor($currPos/2); $moves++; } else if ($currItem > $needle) { $currPos += ceil($currPos/2); } } } echo searchInArray($array, 420);

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.60.0100.01020.36
8.3.50.0140.00523.04
8.3.40.0070.01020.17
8.3.30.0090.00620.71
8.3.20.0090.00021.79
8.3.10.0030.00524.07
8.3.00.0070.00324.66
8.2.180.0150.00418.13
8.2.170.0130.00322.96
8.2.160.0100.00623.16
8.2.150.0100.00024.18
8.2.140.0000.00924.66
8.2.130.0000.00826.16
8.2.120.0040.00421.71
8.2.110.0090.00024.42
8.2.100.0030.00919.53
8.2.90.0060.00320.84
8.2.80.0040.00419.55
8.2.70.0040.00419.13
8.2.60.0040.00419.65
8.2.50.0040.00419.25
8.2.40.0060.00319.78
8.2.30.0000.00819.36
8.2.20.0030.00618.88
8.2.10.0030.00621.26
8.2.00.0000.01018.98
8.1.280.0100.00725.92
8.1.270.0060.00327.89
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00627.86
8.1.230.0090.00322.21
8.1.220.0030.00620.80
8.1.210.0060.00320.48
8.1.200.0070.00320.47
8.1.190.0100.00020.64
8.1.180.0060.00320.35
8.1.170.0060.00321.77
8.1.160.0030.00624.89
8.1.150.0030.00621.62
8.1.140.0000.01020.38
8.1.130.0050.00320.85
8.1.120.0060.00320.26
8.1.110.0060.00320.15
8.1.100.0030.00620.25
8.1.90.0030.00620.13
8.1.80.0000.00920.16
8.1.70.0030.00520.16
8.1.60.0060.00320.39
8.1.50.0040.00420.34
8.1.40.0040.00720.30
8.1.30.0000.00920.32
8.1.20.0100.00020.41
8.1.10.0030.00720.28
8.1.00.0000.00920.26
8.0.300.0040.00720.47
8.0.290.0030.00620.29
8.0.280.0030.00621.19
8.0.270.0040.00420.24
8.0.260.0000.01019.68
8.0.250.0060.00319.68
8.0.240.0030.00619.55
8.0.230.0090.00019.54
8.0.220.0000.00819.58
8.0.210.0000.00819.63
8.0.200.0050.00219.59
8.0.190.0050.00319.66
8.0.180.0080.00019.57
8.0.170.0100.00019.50
8.0.160.0090.00019.53
8.0.150.0080.00019.41
8.0.140.0030.00619.49
8.0.130.0040.00416.04
8.0.120.0080.00019.57
8.0.110.0050.00319.61
8.0.100.0030.00619.58
8.0.90.0060.00319.40
8.0.80.0120.01219.52
8.0.70.0030.00619.46
8.0.60.0080.00019.50
8.0.50.0060.00319.57
8.0.30.0170.00819.66
8.0.20.0170.00819.77
8.0.10.0000.00919.54
8.0.00.0110.01419.40
7.4.330.0030.00318.84
7.4.320.0030.00619.03
7.4.300.0020.00519.11
7.4.290.0030.00719.11
7.4.280.0080.00019.12
7.4.270.0050.00319.24
7.4.260.0080.00019.14
7.4.250.0000.00918.97
7.4.240.0040.00419.08
7.4.230.0080.00019.29
7.4.220.0140.00719.14
7.4.210.0140.00619.13
7.4.200.0060.00319.22
7.4.190.0050.00319.25
7.4.160.0120.00619.09
7.4.150.0180.00319.07
7.4.140.0190.00619.12
7.4.130.0100.01119.28
7.4.120.0080.01219.21
7.4.110.0150.00919.18
7.4.100.0090.01219.08
7.4.90.0200.00819.13
7.4.80.0070.01719.39
7.4.70.0160.00619.22
7.4.60.0100.01019.07
7.4.50.0030.00619.21
7.4.40.0110.00722.77
7.4.30.0090.01219.08
7.4.00.0070.00717.45
7.3.330.0030.00316.01
7.3.320.0000.00615.96
7.3.310.0060.00318.87
7.3.300.0000.00718.98
7.3.290.0070.01018.90
7.3.280.0110.00918.94
7.3.270.0100.01019.08
7.3.260.0070.01419.10
7.3.250.0130.00818.96
7.3.240.0100.01018.93
7.3.230.0150.00619.06
7.3.210.0060.01419.04
7.3.200.0100.01019.39
7.3.190.0140.01018.96
7.3.180.0070.01318.90
7.3.170.0120.00918.92
7.3.160.0090.01218.97
7.3.120.0000.01717.59
7.3.10.0030.01320.48
7.3.00.0070.01020.56
7.2.330.0030.01719.24
7.2.320.0170.00319.16
7.2.310.0130.00619.05
7.2.300.0090.01219.29
7.2.290.0140.00719.14
7.2.130.0000.01720.57
7.2.120.0030.01420.49
7.2.110.0000.01620.61
7.2.100.0070.01120.52
7.2.90.0060.00920.77
7.2.80.0030.00920.49
7.2.70.0060.00920.76
7.2.60.0090.00820.61
7.2.50.0080.00420.39
7.2.40.0120.00320.83
7.2.30.0070.01320.57
7.2.20.0120.00020.86
7.2.10.0100.00620.73
7.2.00.0120.00221.73
7.1.250.0060.01019.45
7.1.200.0090.00619.81
7.1.100.0030.00821.60
7.1.70.0320.00620.74
7.1.60.0160.01021.29
7.1.50.0230.00320.90
7.1.00.0170.06726.28
7.0.200.0170.00720.77
7.0.140.0070.07326.00
7.0.60.0470.06322.88
7.0.50.0170.07720.72
7.0.40.0070.04322.70
7.0.30.0430.07022.80
7.0.20.0230.05722.61
7.0.10.0200.06722.81
7.0.00.0070.07722.76
5.6.280.0100.08734.95
5.6.210.0200.08734.75
5.6.200.0100.08332.18
5.6.190.0170.09734.25
5.6.180.0270.10034.42
5.6.170.0230.05734.27
5.6.160.0170.06734.46
5.6.150.0100.06332.15
5.6.140.0330.04732.15
5.6.130.0100.05732.21
5.6.120.0100.05334.94
5.6.110.0100.07335.18
5.6.100.0100.08735.01
5.6.90.0230.08735.07
5.6.80.0230.06334.45
5.5.350.0230.03034.51
5.5.340.0130.07031.96
5.5.330.0130.10034.05
5.5.320.0030.10034.27
5.5.310.0400.06334.23
5.5.300.0100.04332.00
5.5.290.0230.08032.02
5.5.280.0200.09034.69
5.5.270.0270.07334.88
5.5.260.0400.08034.89
5.5.250.0130.09034.62
5.5.240.0300.05334.20
5.4.450.0600.07033.32
5.4.440.0930.07033.30
5.4.430.0430.08733.25
5.4.420.0370.06733.25
5.4.410.0700.08733.17
5.4.400.0830.06733.24
5.4.390.1100.08733.05
5.4.380.0170.08032.50
5.4.370.0330.05732.76
5.4.360.0300.06332.77
5.4.350.0300.06332.80
5.4.340.0300.06032.75
5.4.320.0110.04426.54
5.4.310.0170.04626.53
5.4.300.0100.05226.54
5.4.290.0100.05226.53
5.4.280.0080.05426.43
5.4.270.0090.04726.40
5.4.260.0130.04326.40
5.4.250.0130.04426.40
5.4.240.0120.04526.40
5.4.230.0090.04726.39
5.4.220.0080.05026.39
5.4.210.0070.04926.39
5.4.200.0070.05026.39
5.4.190.0100.04626.38
5.4.180.0090.05026.39
5.4.170.0100.05026.39
5.4.160.0160.04826.39
5.4.150.0070.04826.39
5.4.140.0110.05126.07
5.4.130.0080.04726.06
5.4.120.0050.05126.02
5.4.110.0110.04426.01
5.4.100.0140.05026.01
5.4.90.0140.04326.01
5.4.80.0090.05326.01
5.4.70.0150.04226.00
5.4.60.0130.04326.01
5.4.50.0110.04526.00
5.4.40.0080.04725.99
5.4.30.0160.04725.99
5.4.20.0120.05725.99
5.4.10.0150.04625.99
5.4.00.0190.03725.48
5.3.290.0180.06026.49
5.3.280.0110.05026.39
5.3.270.0120.05026.40
5.3.260.0150.04526.40
5.3.250.0040.05526.40
5.3.240.0100.04926.40
5.3.230.0150.04326.39
5.3.220.0120.04526.36
5.3.210.0190.05826.36
5.3.200.0100.05226.36
5.3.190.0130.04526.36
5.3.180.0070.05026.36
5.3.170.0140.04526.36
5.3.160.0110.04626.36
5.3.150.0120.05526.36
5.3.140.0090.04726.36
5.3.130.0120.05526.34
5.3.120.0190.05726.34
5.3.110.0080.06926.34
5.3.100.0130.04625.83
5.3.90.0110.04625.81
5.3.80.0170.04525.79
5.3.70.0140.04925.80
5.3.60.0090.04825.78
5.3.50.0080.05425.73
5.3.40.0090.05325.73
5.3.30.0150.05925.69
5.3.20.0130.05825.47
5.3.10.0090.04625.43
5.3.00.0130.04825.42
5.2.170.0080.05422.14
5.2.160.0100.05222.14
5.2.150.0140.05122.14
5.2.140.0110.05822.14
5.2.130.0110.05622.09
5.2.120.0100.05722.10
5.2.110.0100.04422.10
5.2.100.0070.04222.11
5.2.90.0100.04122.11
5.2.80.0070.04922.09
5.2.70.0060.04622.09
5.2.60.0090.04422.04
5.2.50.0140.05622.14
5.2.40.0120.04522.12
5.2.30.0060.05222.09
5.2.20.0090.04822.10
5.2.10.0070.03922.00
5.2.00.0090.03721.86
5.1.60.0060.04125.68
5.1.50.0120.03425.68
5.1.40.0110.03825.67
5.1.30.0120.03826.01
5.1.20.0090.04626.03
5.1.10.0060.04925.77
5.1.00.0130.04125.76
5.0.50.0090.0396.61
5.0.40.0030.0236.47
5.0.30.0020.0366.29
5.0.20.0040.0196.25
5.0.10.0050.0206.23
5.0.00.0040.0326.22
4.4.90.0030.0174.78
4.4.80.0020.0174.76
4.4.70.0060.0134.76
4.4.60.0030.0164.76
4.4.50.0040.0164.77
4.4.40.0040.0264.71
4.4.30.0060.0214.76
4.4.20.0070.0314.84
4.4.10.0110.0184.85
4.4.00.0040.0314.76
4.3.110.0030.0194.67
4.3.100.0030.0184.66
4.3.90.0050.0134.63
4.3.80.0040.0314.58
4.3.70.0050.0194.63
4.3.60.0020.0224.63
4.3.50.0060.0194.62
4.3.40.0030.0324.54
4.3.30.0020.0333.29
4.3.20.0070.0223.27
4.3.10.0040.0193.23
4.3.00.0130.0235.66

preferences:
38.25 ms | 401 KiB | 5 Q