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.0130.00320.62
8.3.50.0110.01322.96
8.3.40.0120.00420.29
8.3.30.0040.01220.75
8.3.20.0080.00021.87
8.3.10.0040.00424.09
8.3.00.0070.00321.85
8.2.180.0000.01520.40
8.2.170.0090.00922.96
8.2.160.0070.00723.20
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0120.00626.16
8.2.120.0060.00319.00
8.2.110.0030.00624.34
8.2.100.0150.00019.47
8.2.90.0040.00420.43
8.2.80.0000.00919.55
8.2.70.0030.00619.13
8.2.60.0040.00419.55
8.2.50.0030.00619.25
8.2.40.0000.00919.72
8.2.30.0050.00319.36
8.2.20.0000.00818.95
8.2.10.0090.00021.20
8.2.00.0040.00818.90
8.1.280.0100.00725.92
8.1.270.0030.00625.20
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0110.00027.89
8.1.230.0100.00322.29
8.1.220.0090.00020.91
8.1.210.0000.00920.36
8.1.200.0030.00720.35
8.1.190.0060.00320.63
8.1.180.0090.00020.23
8.1.170.0030.00621.71
8.1.160.0060.00325.03
8.1.150.0000.00921.58
8.1.140.0030.00620.37
8.1.130.0030.00620.84
8.1.120.0060.00320.13
8.1.110.0080.00020.17
8.1.100.0030.00620.19
8.1.90.0030.00620.16
8.1.80.0030.00520.23
8.1.70.0050.00520.22
8.1.60.0100.00020.34
8.1.50.0030.00720.29
8.1.40.0030.00620.26
8.1.30.0070.00320.32
8.1.20.0000.00920.37
8.1.10.0030.00620.30
8.1.00.0070.00320.21
8.0.300.0060.00320.29
8.0.290.0040.00420.30
8.0.280.0000.00821.35
8.0.270.0050.00320.16
8.0.260.0080.00419.73
8.0.250.0040.00419.64
8.0.240.0000.00919.50
8.0.230.0080.00019.54
8.0.220.0030.00619.55
8.0.210.0080.00019.52
8.0.200.0060.00319.61
8.0.190.0090.00019.60
8.0.180.0030.00619.45
8.0.170.0000.01019.61
8.0.160.0030.00619.47
8.0.150.0000.00919.50
8.0.140.0050.00519.41
8.0.130.0050.00316.07
8.0.120.0090.00019.36
8.0.110.0000.00919.41
8.0.100.0060.00319.53
8.0.90.0000.00919.32
8.0.80.0120.00619.54
8.0.70.0000.00919.42
8.0.60.0090.00019.43
8.0.50.0090.00019.42
8.0.30.0110.01219.68
8.0.20.0120.01319.65
8.0.10.0090.00019.65
8.0.00.0100.01619.42
7.4.330.0030.00318.79
7.4.320.0000.00719.17
7.4.300.0030.00519.09
7.4.290.0070.00719.16
7.4.280.0080.00019.05
7.4.270.0040.00418.99
7.4.260.0000.00819.02
7.4.250.0040.00419.04
7.4.240.0030.00619.15
7.4.230.0040.00418.99
7.4.220.0210.01219.22
7.4.210.0070.01219.12
7.4.200.0060.00319.27
7.4.190.0080.00019.05
7.4.160.0150.00918.96
7.4.150.0150.00619.09
7.4.140.0140.00719.17
7.4.130.0170.00219.19
7.4.120.0110.01019.12
7.4.110.0080.01119.11
7.4.100.0170.00319.20
7.4.90.0220.01019.16
7.4.80.0090.01619.39
7.4.70.0100.01719.16
7.4.60.0220.00019.00
7.4.50.0060.00318.84
7.4.40.0030.01322.77
7.4.30.0140.00519.20
7.4.00.0090.00917.48
7.3.330.0030.00316.04
7.3.320.0030.00315.78
7.3.310.0000.00918.99
7.3.300.0000.00818.71
7.3.290.0000.01918.95
7.3.280.0110.00818.87
7.3.270.0120.00818.90
7.3.260.0200.00719.13
7.3.250.0120.01319.02
7.3.240.0130.00618.95
7.3.230.0120.00919.17
7.3.210.0140.00619.11
7.3.200.0120.01219.39
7.3.190.0120.01519.06
7.3.180.0130.00618.89
7.3.170.0140.01019.06
7.3.160.0120.00618.88
7.3.120.0030.01517.11
7.2.330.0130.01019.41
7.2.320.0320.01318.98
7.2.310.0100.01019.06
7.2.300.0090.01219.16
7.2.290.0070.01319.39
7.2.00.0030.01322.93
7.1.100.0090.00321.64
7.1.70.0220.00320.85
7.1.60.0030.01021.18
7.1.50.0040.01820.53
7.1.00.0030.07726.34
7.0.200.0140.01020.44
7.0.140.0030.07326.18
7.0.60.0230.07324.54
7.0.50.0070.04020.72
7.0.40.0070.08722.55
7.0.30.0470.07022.63
7.0.20.0270.05322.81
7.0.10.0200.08322.62
7.0.00.0130.07722.71
5.6.280.0100.08735.15
5.6.210.0300.08334.50
5.6.200.0070.06332.18
5.6.190.0070.05334.38
5.6.180.0130.04734.39
5.6.170.0300.09034.46
5.6.160.0100.10034.18
5.6.150.0070.09732.22
5.6.140.0230.07732.15
5.6.130.0130.10032.02
5.6.120.0100.04735.05
5.6.110.0100.09035.05
5.6.100.0100.10335.03
5.6.90.0400.07035.02
5.6.80.0170.09334.44
5.5.350.0270.07034.47
5.5.340.0070.05031.97
5.5.330.0130.05034.20
5.5.320.0370.07034.27
5.5.310.0400.09034.00
5.5.300.0100.09331.98
5.5.290.0200.06331.98
5.5.280.0130.09734.99
5.5.270.0170.06034.71
5.5.260.0030.05734.93
5.5.250.0130.07334.57
5.5.240.0330.07734.11
5.4.450.0600.05333.29
5.4.440.0300.04033.42
5.4.430.0470.05733.53
5.4.420.0430.03733.36
5.4.410.0200.06332.95
5.4.400.0230.06032.54
5.4.390.0300.05332.77
5.4.380.0270.06332.62
5.4.370.0230.06332.74
5.4.360.0130.08032.77
5.4.350.0300.07032.78
5.4.340.0130.07032.50
5.4.320.0060.05226.54
5.4.310.0110.04726.53
5.4.300.0180.04726.54
5.4.290.0120.04626.53
5.4.280.0150.04126.43
5.4.270.0140.05926.39
5.4.260.0090.05126.39
5.4.250.0110.04826.40
5.4.240.0070.04926.39
5.4.230.0130.04726.38
5.4.220.0110.04626.39
5.4.210.0120.04926.38
5.4.200.0110.04826.38
5.4.190.0120.04826.38
5.4.180.0090.05826.39
5.4.170.0170.04826.39
5.4.160.0110.04826.39
5.4.150.0100.05126.39
5.4.140.0110.05226.07
5.4.130.0100.04726.06
5.4.120.0100.05126.02
5.4.110.0070.06126.01
5.4.100.0080.04826.01
5.4.90.0110.06626.01
5.4.80.0170.05926.01
5.4.70.0090.04826.01
5.4.60.0070.05226.01
5.4.50.0140.04526.00
5.4.40.0110.05026.00
5.4.30.0090.05025.99
5.4.20.0100.05025.97
5.4.10.0130.04425.99
5.4.00.0100.04825.47
5.3.290.0110.05226.50
5.3.280.0080.05026.39
5.3.270.0120.05426.40
5.3.260.0120.06226.41
5.3.250.0070.05326.40
5.3.240.0090.04826.40
5.3.230.0100.04626.39
5.3.220.0080.05126.36
5.3.210.0120.05026.36
5.3.200.0070.05026.36
5.3.190.0090.04926.37
5.3.180.0080.05126.36
5.3.170.0110.04626.36
5.3.160.0110.04726.36
5.3.150.0110.04726.36
5.3.140.0110.04526.35
5.3.130.0140.04826.34
5.3.120.0070.05326.34
5.3.110.0130.04726.34
5.3.100.0100.04725.84
5.3.90.0100.05025.81
5.3.80.0080.04825.80
5.3.70.0090.04725.80
5.3.60.0080.05025.78
5.3.50.0080.04925.73
5.3.40.0090.05125.73
5.3.30.0120.04425.69
5.3.20.0110.04525.48
5.3.10.0090.05525.43
5.3.00.0120.04625.42
5.2.170.0080.05722.14
5.2.160.0100.04222.15
5.2.150.0090.04122.14
5.2.140.0100.04822.14
5.2.130.0080.04222.11
5.2.120.0140.04222.11
5.2.110.0050.04322.10
5.2.100.0070.04722.11
5.2.90.0080.03922.11
5.2.80.0060.04522.11
5.2.70.0120.04022.10
5.2.60.0100.03822.05
5.2.50.0100.05222.16
5.2.40.0110.04922.13
5.2.30.0100.05122.11
5.2.20.0090.05122.11
5.2.10.0110.03522.03
5.2.00.0050.04321.87
5.1.60.0110.03525.69
5.1.50.0100.04125.69
5.1.40.0070.03925.67
5.1.30.0090.03826.01
5.1.20.0060.04226.03
5.1.10.0080.04225.77
5.1.00.0100.03825.77
5.0.50.0030.0216.61
5.0.40.0080.0166.47
5.0.30.0030.0336.29
5.0.20.0030.0206.25
5.0.10.0030.0226.23
5.0.00.0050.0306.22
4.4.90.0040.0154.78
4.4.80.0030.0154.76
4.4.70.0020.0164.75
4.4.60.0020.0164.75
4.4.50.0000.0184.77
4.4.40.0040.0244.70
4.4.30.0010.0174.76
4.4.20.0030.0154.84
4.4.10.0050.0144.85
4.4.00.0050.0264.76
4.3.110.0020.0174.67
4.3.100.0030.0154.66
4.3.90.0030.0194.63
4.3.80.0010.0274.58
4.3.70.0030.0144.63
4.3.60.0030.0144.63
4.3.50.0040.0144.62
4.3.40.0050.0224.54
4.3.30.0020.0163.29
4.3.20.0020.0163.27
4.3.10.0020.0153.23
4.3.00.0070.01313.29

preferences:
47.37 ms | 400 KiB | 5 Q