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) { echo "Move: $moves. Current: $currPos:$currItem\n"; $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); $moves++; } } } 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.70.0100.01018.38
8.3.60.0080.01120.49
8.3.50.0070.01122.94
8.3.40.0160.00320.47
8.3.30.0170.00020.61
8.3.20.0060.00321.93
8.3.10.0050.00324.14
8.3.00.0090.00324.43
8.2.190.0100.01318.00
8.2.180.0070.01118.38
8.2.170.0160.00022.96
8.2.160.0040.01123.05
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0060.01326.16
8.2.120.0040.00419.38
8.2.110.0090.00024.48
8.2.100.0060.00619.53
8.2.90.0000.00820.80
8.2.80.0030.00619.55
8.2.70.0030.00619.25
8.2.60.0050.00319.55
8.2.50.0000.00819.13
8.2.40.0070.00419.78
8.2.30.0060.00319.24
8.2.20.0050.00318.96
8.2.10.0030.00619.03
8.2.00.0110.00018.97
8.1.280.0100.00725.92
8.1.270.0090.00025.31
8.1.260.0060.00326.35
8.1.250.0090.00028.09
8.1.240.0060.00328.04
8.1.230.0030.01022.34
8.1.220.0060.00320.93
8.1.210.0060.00320.61
8.1.200.0070.00320.48
8.1.190.0060.00320.53
8.1.180.0030.00620.35
8.1.170.0070.00321.81
8.1.160.0030.00625.05
8.1.150.0080.00021.42
8.1.140.0080.00020.34
8.1.130.0040.00420.85
8.1.120.0030.00520.14
8.1.110.0000.00820.07
8.1.100.0040.00420.11
8.1.90.0060.00320.26
8.1.80.0030.00620.23
8.1.70.0030.00620.11
8.1.60.0000.00920.36
8.1.50.0030.00720.30
8.1.40.0070.00420.35
8.1.30.0060.00320.34
8.1.20.0000.01020.36
8.1.10.0030.00720.36
8.1.00.0090.00020.11
8.0.300.0080.00020.35
8.0.290.0030.00720.16
8.0.280.0000.00821.36
8.0.270.0030.00620.07
8.0.260.0090.00319.64
8.0.250.0000.00819.50
8.0.240.0030.00619.51
8.0.230.0000.00919.63
8.0.220.0080.00019.38
8.0.210.0040.00419.48
8.0.200.0040.00419.53
8.0.190.0040.00419.63
8.0.180.0080.00019.50
8.0.170.0000.01019.63
8.0.160.0060.00319.54
8.0.150.0000.00819.53
8.0.140.0050.00519.40
8.0.130.0070.00016.04
8.0.120.0030.00619.48
8.0.110.0040.00419.51
8.0.100.0000.00919.35
8.0.90.0040.00419.75
8.0.80.0070.01719.45
8.0.70.0000.00919.36
8.0.60.0030.00619.37
8.0.50.0060.00319.29
8.0.30.0100.01319.63
8.0.20.0110.01319.92
8.0.10.0030.00619.67
8.0.00.0100.01319.37
7.4.330.0030.00318.79
7.4.320.0040.00419.11
7.4.300.0040.00419.16
7.4.290.0060.00319.19
7.4.280.0030.00619.20
7.4.270.0030.00519.15
7.4.260.0040.00419.09
7.4.250.0030.00619.15
7.4.240.0070.00219.18
7.4.230.0060.00319.28
7.4.220.0060.01619.01
7.4.210.0120.00919.17
7.4.200.0000.00919.07
7.4.190.0090.00019.25
7.4.160.0180.00919.13
7.4.150.0220.00319.05
7.4.140.0140.01019.13
7.4.130.0090.01219.04
7.4.120.0160.00519.14
7.4.110.0090.01219.04
7.4.100.0070.01319.18
7.4.90.0150.00619.15
7.4.80.0100.01419.39
7.4.70.0130.01319.12
7.4.60.0130.00718.95
7.4.50.0030.00719.28
7.4.40.0060.01222.77
7.4.30.0150.00419.19
7.4.00.0050.01117.46
7.3.330.0030.00315.98
7.3.320.0030.00315.85
7.3.310.0040.00418.70
7.3.300.0030.00618.74
7.3.290.0070.01518.86
7.3.280.0110.01018.92
7.3.270.0080.01319.18
7.3.260.0030.01718.85
7.3.250.0110.01418.98
7.3.240.0130.00719.15
7.3.230.0160.00618.93
7.3.210.0200.00019.36
7.3.200.0060.01319.39
7.3.190.0170.00619.07
7.3.180.0110.00919.02
7.3.170.0160.00918.87
7.3.160.0060.01218.88
7.3.120.0140.00717.41
7.3.110.0080.01317.38
7.3.100.0080.01017.40
7.3.90.0090.00817.56
7.3.80.0090.00717.58
7.3.70.0090.00717.44
7.3.60.0040.01117.47
7.3.50.0050.00917.45
7.3.40.0040.01017.41
7.3.30.0070.00317.29
7.3.20.0050.00820.47
7.3.10.0070.00720.58
7.3.00.0080.00720.37
7.2.330.0110.01119.18
7.2.320.0150.00619.30
7.2.310.0150.00419.28
7.2.300.0130.01218.97
7.2.290.0030.02119.11
7.2.250.0120.00917.55
7.2.240.0120.00917.55
7.2.230.0080.01217.37
7.2.220.0130.00517.67
7.2.210.0130.00617.41
7.2.200.0090.00317.55
7.2.190.0050.00817.65
7.2.180.0040.01017.58
7.2.170.0080.00617.67
7.2.160.0100.00717.49
7.2.150.0000.00920.81
7.2.140.0030.00920.63
7.2.130.0030.01320.81
7.2.120.0140.00020.72
7.2.110.0030.01020.58
7.2.100.0070.00420.55
7.2.90.0070.00720.73
7.2.80.0090.00920.53
7.2.70.0120.00420.79
7.2.60.0050.00620.55
7.2.50.0030.01320.46
7.2.40.0060.01020.66
7.2.30.0070.00720.71
7.2.20.0060.01020.61
7.2.10.0040.00720.37
7.2.00.0050.01121.82
7.1.330.0080.00919.62
7.1.320.0090.00519.34
7.1.310.0030.01219.39
7.1.300.0020.01019.70
7.1.290.0020.01019.58
7.1.280.0040.00719.57
7.1.270.0040.01119.51
7.1.260.0050.00919.41
7.1.250.0060.01219.69
7.1.200.0180.00819.25
7.1.100.1090.01418.93
7.1.70.0220.00620.79
7.1.60.0100.01621.16
7.1.50.0130.01320.83
7.1.00.0070.07726.36
7.0.200.0220.00420.47
7.0.140.0070.07326.00
7.0.60.0000.04322.66
7.0.50.0100.08020.72
7.0.40.0100.08022.70
7.0.30.0370.05322.64
7.0.20.0330.07722.64
7.0.10.0030.04322.64
7.0.00.0130.08322.54
5.6.280.0100.08334.86
5.6.210.0100.08334.75
5.6.200.0100.04732.17
5.6.190.0100.06034.39
5.6.180.0370.03734.43
5.6.170.0230.06034.49
5.6.160.0130.05034.36
5.6.150.0200.08032.18
5.6.140.0030.10332.27
5.6.130.0230.06332.15
5.6.120.0130.05335.03
5.6.110.0100.10335.09
5.6.100.0070.05034.99
5.6.90.0130.10035.05
5.6.80.0170.07034.39
5.5.350.3370.05334.46
5.5.340.0070.07331.98
5.5.330.0130.08734.30
5.5.320.0270.07734.16
5.5.310.0370.07734.23
5.5.300.0070.05031.96
5.5.290.0200.08331.83
5.5.280.0030.05335.01
5.5.270.0100.08334.83
5.5.260.0100.06034.68
5.5.250.0030.05334.72
5.5.240.0100.09734.11
5.4.450.0770.06333.43
5.4.440.0970.06333.43
5.4.430.0400.05033.57
5.4.420.0230.06733.41
5.4.410.0300.07032.96
5.4.400.0230.06332.79
5.4.390.0200.06732.81
5.4.380.0200.07032.77
5.4.370.0330.05332.59
5.4.360.0200.06732.62
5.4.350.0400.05732.60
5.4.340.0300.06032.59
5.4.320.0090.06226.54
5.4.310.0120.06826.54
5.4.300.0130.05526.53
5.4.290.0110.05626.54
5.4.280.0120.04526.43
5.4.270.0140.04226.40
5.4.260.0090.05126.39
5.4.250.0110.05026.39
5.4.240.0090.04726.39
5.4.230.0050.05426.38
5.4.220.0110.04526.39
5.4.210.0090.04926.39
5.4.200.0070.05526.39
5.4.190.0110.04726.38
5.4.180.0110.04826.39
5.4.170.0120.04926.39
5.4.160.0110.04426.39
5.4.150.0100.04826.39
5.4.140.0080.05026.07
5.4.130.0070.04926.06
5.4.120.0090.04826.02
5.4.110.0150.04626.01
5.4.100.0070.06326.02
5.4.90.0110.05326.01
5.4.80.0100.06026.01
5.4.70.0140.04126.01
5.4.60.0100.04526.01
5.4.50.0090.05126.00
5.4.40.0120.04325.99
5.4.30.0090.05025.99
5.4.20.0130.04725.99
5.4.10.0080.04725.99
5.4.00.0090.04825.48
5.3.290.0150.05126.49
5.3.280.0150.04326.39
5.3.270.0220.05826.40
5.3.260.0070.06026.40
5.3.250.0080.04926.40
5.3.240.0120.04626.40
5.3.230.0110.06826.39
5.3.220.0080.05326.36
5.3.210.0130.06526.36
5.3.200.0100.05726.36
5.3.190.0110.05026.37
5.3.180.0090.04726.36
5.3.170.0070.05226.36
5.3.160.0070.05026.36
5.3.150.0140.05226.36
5.3.140.0090.05226.35
5.3.130.0090.05426.34
5.3.120.0170.06426.34
5.3.110.0120.04926.34
5.3.100.0100.04725.83
5.3.90.0100.04725.82
5.3.80.0100.05625.80
5.3.70.0130.05225.80
5.3.60.0140.05025.79
5.3.50.0070.05025.73
5.3.40.0150.07025.73
5.3.30.0150.05025.70
5.3.20.0080.05025.47
5.3.10.0100.04925.44
5.3.00.0160.04425.42
5.2.170.0110.04422.14
5.2.160.0150.03822.15
5.2.150.0080.04822.15
5.2.140.0160.04622.14
5.2.130.0040.04922.11
5.2.120.0080.04122.11
5.2.110.0120.04922.10
5.2.100.0130.05022.11
5.2.90.0080.05422.11
5.2.80.0110.04122.09
5.2.70.0130.03722.09
5.2.60.0110.03922.05
5.2.50.0090.04822.15
5.2.40.0100.04722.12
5.2.30.0080.05222.10
5.2.20.0090.04922.11
5.2.10.0130.03722.02
5.2.00.0040.04821.87
5.1.60.0120.04925.68
5.1.50.0110.04025.68
5.1.40.0040.04225.66
5.1.30.0070.04026.01
5.1.20.0120.03726.04
5.1.10.0100.04025.77
5.1.00.0080.04125.76
5.0.50.0040.0206.61
5.0.40.0040.0196.47
5.0.30.0040.0396.29
5.0.20.0030.0266.25
5.0.10.0010.0236.23
5.0.00.0030.0316.22
4.4.90.0030.0164.78
4.4.80.0040.0174.76
4.4.70.0060.0124.75
4.4.60.0050.0134.75
4.4.50.0040.0154.77
4.4.40.0040.0334.71
4.4.30.0000.0224.76
4.4.20.0050.0144.84
4.4.10.0040.0164.85
4.4.00.0040.0274.76
4.3.110.0020.0174.67
4.3.100.0030.0154.66
4.3.90.0040.0154.64
4.3.80.0030.0274.58
4.3.70.0050.0154.63
4.3.60.0040.0134.63
4.3.50.0020.0174.62
4.3.40.0030.0244.54
4.3.30.0010.0173.29
4.3.20.0010.0173.27
4.3.10.0010.0173.23
4.3.00.0000.01313.29

preferences:
47.02 ms | 401 KiB | 5 Q