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]; echo "Move: $moves. Current: $currPos:$currItem Searching from $bottomBoundry to $topBoundry\n"; if ($currItem == $needle) { echo "Found item in $moves moves!"; return $currPos; } else if ($currItem > $needle) { echo "LARGER! Let's go smaller! "; $topBoundry = $currPos; $currPos = floor(($currPos+$bottomBoundry)/2); $moves++; } else if ($currItem < $needle) { echo "SMALLER! Let's go larger! "; $bottomBoundry = $currPos; $currPos = ceil(($currPos+$topBoundry)/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.60.0080.00820.32
8.3.50.0170.00623.13
8.3.40.0060.01020.46
8.3.30.0100.00620.53
8.3.20.0090.00021.96
8.3.10.0080.00023.98
8.3.00.0080.00321.93
8.2.180.0100.00718.13
8.2.170.0130.00622.96
8.2.160.0040.01123.02
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0090.00626.16
8.2.120.0040.00422.05
8.2.110.0090.00024.33
8.2.100.0080.00819.53
8.2.90.0040.00420.97
8.2.80.0060.00319.54
8.2.70.0000.01019.25
8.2.60.0000.00919.65
8.2.50.0000.01119.25
8.2.40.0030.00719.78
8.2.30.0040.00419.24
8.2.20.0040.00419.06
8.2.10.0000.00821.17
8.2.00.0030.00919.00
8.1.280.0130.00625.92
8.1.270.0130.00325.20
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0060.00327.91
8.1.230.0140.00022.35
8.1.220.0000.00920.86
8.1.210.0090.00020.36
8.1.200.0000.01020.35
8.1.190.0060.00320.55
8.1.180.0060.00320.13
8.1.170.0030.00721.82
8.1.160.0030.00625.02
8.1.150.0030.00621.57
8.1.140.0030.00620.39
8.1.130.0030.00620.86
8.1.120.0030.00620.28
8.1.110.0040.00420.13
8.1.100.0030.00620.20
8.1.90.0090.00020.25
8.1.80.0090.00020.15
8.1.70.0000.00820.21
8.1.60.0030.00720.39
8.1.50.0040.00420.30
8.1.40.0030.00620.19
8.1.30.0000.00920.24
8.1.20.0050.00520.36
8.1.10.0050.00520.25
8.1.00.0030.00720.27
8.0.300.0030.00620.47
8.0.290.0090.00020.16
8.0.280.0030.00621.31
8.0.270.0040.00420.29
8.0.260.0080.00419.82
8.0.250.0050.00319.59
8.0.240.0030.00519.50
8.0.230.0030.00619.66
8.0.220.0080.00019.55
8.0.210.0000.00819.50
8.0.200.0000.00719.62
8.0.190.0040.00419.55
8.0.180.0040.00419.48
8.0.170.0000.01019.59
8.0.160.0030.00619.45
8.0.150.0000.00819.61
8.0.140.0050.00519.56
8.0.130.0040.00415.99
8.0.120.0030.00619.47
8.0.110.0030.00619.61
8.0.100.0050.00519.38
8.0.90.0030.00619.53
8.0.80.0040.01419.54
8.0.70.0040.00419.51
8.0.60.0100.00019.51
8.0.50.0090.00019.46
8.0.30.0090.01619.64
8.0.20.0160.01219.59
8.0.10.0090.00019.49
8.0.00.0080.01419.31
7.4.330.0000.00518.84
7.4.320.0000.00819.08
7.4.300.0000.00819.14
7.4.290.0030.00619.15
7.4.280.0090.00019.08
7.4.270.0000.00819.06
7.4.260.0040.00419.11
7.4.250.0090.00019.17
7.4.240.0050.00519.14
7.4.230.0040.00419.09
7.4.220.0140.01419.27
7.4.210.0100.00819.19
7.4.200.0090.00019.07
7.4.190.0000.00919.29
7.4.160.0070.01318.93
7.4.150.0070.01319.24
7.4.140.0090.01219.17
7.4.130.0080.01319.09
7.4.120.0170.00419.06
7.4.110.0120.00919.04
7.4.100.0120.00919.03
7.4.90.0150.00619.18
7.4.80.0130.01319.39
7.4.70.0140.01219.09
7.4.60.0100.01019.11
7.4.50.0040.00719.06
7.4.40.0030.01722.77
7.4.30.0100.01019.02
7.4.00.0030.01617.22
7.3.330.0030.00316.08
7.3.320.0060.00016.02
7.3.310.0090.00018.84
7.3.300.0040.00418.88
7.3.290.0090.01218.96
7.3.280.0100.00818.89
7.3.270.0090.01218.84
7.3.260.0130.00819.20
7.3.250.0090.01618.85
7.3.240.0140.00719.19
7.3.230.0130.00619.10
7.3.210.0120.00918.97
7.3.200.0030.01619.39
7.3.190.0150.00618.88
7.3.180.0160.00318.95
7.3.170.0120.00919.04
7.3.160.0090.00918.92
7.3.120.0120.00017.52
7.2.330.0140.01419.14
7.2.320.0100.01119.09
7.2.310.0180.00319.22
7.2.300.0060.01618.96
7.2.290.0130.00918.96
7.2.00.0000.01422.95
7.1.100.1580.01019.98
7.1.70.0190.00620.94
7.1.60.0100.01721.32
7.1.50.0070.02020.98
7.1.00.0070.07026.27
7.0.200.0200.00820.61
7.0.140.0000.08026.19
7.0.60.0270.07324.42
7.0.50.0100.08320.65
7.0.40.0100.04722.55
7.0.30.0330.04722.70
7.0.20.0330.08022.83
7.0.10.0100.08322.70
7.0.00.0070.08022.75
5.6.280.0100.08734.90
5.6.210.0070.06334.54
5.6.200.0100.08032.18
5.6.190.0130.10334.39
5.6.180.0100.04734.50
5.6.170.0270.09334.38
5.6.160.0030.05334.39
5.6.150.0100.05032.22
5.6.140.0130.06332.14
5.6.130.0170.09332.25
5.6.120.0200.09335.07
5.6.110.0100.07735.18
5.6.100.0100.05035.15
5.6.90.0100.05034.99
5.6.80.0100.09734.57
5.5.350.0130.07734.50
5.5.340.0200.08332.08
5.5.330.0270.06034.30
5.5.320.0270.04734.20
5.5.310.0230.05334.20
5.5.300.0130.08731.99
5.5.290.0130.09331.93
5.5.280.0100.06034.69
5.5.270.0070.07334.91
5.5.260.0070.10734.92
5.5.250.0170.04034.72
5.5.240.0330.02334.32
5.4.450.0570.04733.52
5.4.440.0400.05733.61
5.4.430.0070.04733.24
5.4.420.0300.05333.37
5.4.410.0230.06333.06
5.4.400.0170.07032.75
5.4.390.0200.06732.62
5.4.380.0270.06332.60
5.4.370.0300.05732.77
5.4.360.0170.07732.58
5.4.350.0200.07332.79
5.4.340.0370.06732.80
5.4.320.0100.04726.54
5.4.310.0090.05526.53
5.4.300.0090.05326.54
5.4.290.0150.04326.54
5.4.280.0080.05326.43
5.4.270.0110.05026.39
5.4.260.0090.04926.39
5.4.250.0100.04826.39
5.4.240.0100.04626.39
5.4.230.0090.05026.39
5.4.220.0110.04626.39
5.4.210.0050.05126.38
5.4.200.0090.06526.39
5.4.190.0120.04626.38
5.4.180.0130.06326.38
5.4.170.0090.04726.39
5.4.160.0130.06026.39
5.4.150.0100.04726.39
5.4.140.0090.04926.07
5.4.130.0100.04626.06
5.4.120.0100.04526.02
5.4.110.0120.04326.01
5.4.100.0140.04226.02
5.4.90.0060.05226.01
5.4.80.0130.04426.01
5.4.70.0110.04526.01
5.4.60.0110.04526.00
5.4.50.0110.04926.01
5.4.40.0110.04625.99
5.4.30.0030.05825.99
5.4.20.0130.05425.99
5.4.10.0120.04825.99
5.4.00.0090.04825.48
5.3.290.0100.04926.49
5.3.280.0090.04926.39
5.3.270.0130.05026.40
5.3.260.0140.06926.40
5.3.250.0110.04926.40
5.3.240.0060.05426.40
5.3.230.0100.05026.39
5.3.220.0120.04926.37
5.3.210.0090.05226.36
5.3.200.0110.04726.36
5.3.190.0140.04626.37
5.3.180.0100.05926.36
5.3.170.0120.04826.36
5.3.160.0180.06126.36
5.3.150.0180.06126.36
5.3.140.0150.06626.35
5.3.130.0060.05326.34
5.3.120.0140.04626.34
5.3.110.0130.06126.34
5.3.100.0130.04725.83
5.3.90.0110.04625.82
5.3.80.0090.04725.80
5.3.70.0090.05025.80
5.3.60.0120.05025.79
5.3.50.0130.04825.73
5.3.40.0110.05025.73
5.3.30.0080.05125.69
5.3.20.0070.05125.48
5.3.10.0110.04525.44
5.3.00.0070.05125.42
5.2.170.0080.04622.15
5.2.160.0110.05022.14
5.2.150.0090.04222.15
5.2.140.0060.04322.14
5.2.130.0100.03822.11
5.2.120.0050.04322.10
5.2.110.0060.04222.10
5.2.100.0120.03822.11
5.2.90.0110.04022.32
5.2.80.0110.03922.10
5.2.70.0120.03822.10
5.2.60.0090.04222.05
5.2.50.0080.05122.16
5.2.40.0080.04922.13
5.2.30.0110.06422.11
5.2.20.0100.05122.11
5.2.10.0080.03922.02
5.2.00.0090.03721.88
5.1.60.0140.03925.69
5.1.50.0110.04125.68
5.1.40.0110.04625.67
5.1.30.0130.05326.02
5.1.20.0130.05526.03
5.1.10.0120.03525.77
5.1.00.0100.03925.76
5.0.50.0050.0226.61
5.0.40.0050.0216.47
5.0.30.0030.0376.29
5.0.20.0030.0206.25
5.0.10.0050.0236.23
5.0.00.0040.0346.22
4.4.90.0020.0194.78
4.4.80.0000.0194.75
4.4.70.0070.0154.76
4.4.60.0050.0134.76
4.4.50.0050.0134.77
4.4.40.0050.0244.70
4.4.30.0010.0184.76
4.4.20.0060.0124.84
4.4.10.0030.0154.85
4.4.00.0050.0234.76
4.3.110.0010.0174.67
4.3.100.0020.0154.66
4.3.90.0020.0164.63
4.3.80.0050.0224.58
4.3.70.0030.0174.63
4.3.60.0030.0144.62
4.3.50.0040.0204.62
4.3.40.0040.0314.54
4.3.30.0030.0213.29
4.3.20.0030.0193.27
4.3.10.0040.0133.24
4.3.00.0230.01713.29

preferences:
48.47 ms | 401 KiB | 5 Q