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\n"; 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.60.0120.00320.36
8.3.50.0080.01423.10
8.3.40.0080.00820.42
8.3.30.0160.00020.73
8.3.20.0000.00921.88
8.3.10.0030.00624.12
8.3.00.0060.00622.30
8.2.180.0070.01020.52
8.2.170.0120.00422.96
8.2.160.0090.00623.20
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0090.00026.16
8.2.120.0090.00019.38
8.2.110.0050.00522.15
8.2.100.0080.00419.53
8.2.90.0090.00020.77
8.2.80.0040.00419.25
8.2.70.0060.00319.25
8.2.60.0040.00419.68
8.2.50.0000.00919.00
8.2.40.0070.00419.84
8.2.30.0060.00319.36
8.2.20.0080.00018.92
8.2.10.0040.00421.13
8.2.00.0080.00318.88
8.1.280.0080.00825.92
8.1.270.0130.00325.03
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0100.00028.07
8.1.230.0130.00020.95
8.1.220.0060.00320.89
8.1.210.0030.00720.60
8.1.200.0000.01020.48
8.1.190.0060.00322.09
8.1.180.0050.00520.35
8.1.170.0090.00021.78
8.1.160.0000.00824.97
8.1.150.0030.00621.45
8.1.140.0060.00320.30
8.1.130.0050.00320.89
8.1.120.0040.00420.29
8.1.110.0030.00620.27
8.1.100.0090.00020.26
8.1.90.0030.00620.15
8.1.80.0030.00620.24
8.1.70.0090.00020.20
8.1.60.0030.00620.32
8.1.50.0040.00720.34
8.1.40.0030.00620.18
8.1.30.0000.01020.39
8.1.20.0040.00420.41
8.1.10.0000.00920.33
8.1.00.0040.00420.24
8.0.300.0090.00021.10
8.0.290.0090.00019.75
8.0.280.0050.00321.20
8.0.270.0000.00820.13
8.0.260.0120.00019.66
8.0.250.0040.00419.53
8.0.240.0040.00419.47
8.0.230.0060.00319.49
8.0.220.0040.00419.45
8.0.210.0030.00619.38
8.0.200.0040.00419.64
8.0.190.0080.00019.49
8.0.180.0040.00419.57
8.0.170.0030.00719.59
8.0.160.0000.00919.61
8.0.150.0080.00019.50
8.0.140.0060.00319.40
8.0.130.0000.00716.06
8.0.120.0000.00919.54
8.0.110.0000.00919.51
8.0.100.0060.00319.35
8.0.90.0030.00619.43
8.0.80.0090.01519.48
8.0.70.0090.00019.54
8.0.60.0030.00619.44
8.0.50.0040.00419.44
8.0.30.0100.01619.54
8.0.20.0120.01119.75
8.0.10.0000.00919.59
8.0.00.0170.00819.31
7.4.330.0000.00618.75
7.4.320.0060.00319.11
7.4.300.0030.00519.04
7.4.290.0070.00318.98
7.4.280.0070.00318.97
7.4.270.0080.00019.10
7.4.260.0000.00819.18
7.4.250.0060.00319.13
7.4.240.0060.00319.11
7.4.230.0040.00419.29
7.4.220.0080.01219.15
7.4.210.0100.00719.12
7.4.200.0000.01019.21
7.4.190.0000.00819.04
7.4.160.0170.00319.07
7.4.150.0100.01319.21
7.4.140.0150.00519.05
7.4.130.0160.00519.20
7.4.120.0140.00619.08
7.4.110.0140.00719.18
7.4.100.0070.01619.28
7.4.90.0120.00819.23
7.4.80.0070.01719.39
7.4.70.0100.01719.20
7.4.60.0120.00919.20
7.4.50.0000.00618.96
7.4.40.0060.00622.77
7.4.30.0030.01519.12
7.4.00.0070.01317.61
7.3.330.0030.00315.96
7.3.320.0030.00315.98
7.3.310.0000.00918.87
7.3.300.0000.00918.77
7.3.290.0090.01318.88
7.3.280.0100.01318.87
7.3.270.0160.00618.97
7.3.260.0100.01018.80
7.3.250.0120.01218.89
7.3.240.0160.01019.17
7.3.230.0160.00619.15
7.3.210.0150.00619.05
7.3.200.0100.00919.39
7.3.190.0140.00719.03
7.3.180.0150.00418.84
7.3.170.0100.01019.04
7.3.160.0060.01318.86
7.3.120.0090.01117.64
7.3.110.0080.01017.39
7.3.100.0110.00517.53
7.3.90.0050.01317.40
7.3.80.0060.00617.35
7.3.70.0080.00817.39
7.3.60.0050.01317.58
7.3.50.0040.00917.37
7.3.40.0110.00317.44
7.3.30.0050.00817.38
7.3.20.0120.01120.42
7.3.10.0050.00820.43
7.3.00.0060.00620.43
7.2.330.0180.00319.07
7.2.320.0160.00919.16
7.2.310.0120.00819.30
7.2.300.0130.00719.29
7.2.290.0080.02018.99
7.2.250.0100.01017.61
7.2.240.0060.00917.61
7.2.230.0130.00517.59
7.2.220.0060.01017.42
7.2.210.0100.00817.65
7.2.200.0060.00817.71
7.2.190.0090.00917.73
7.2.180.0070.00917.68
7.2.170.0050.01017.53
7.2.160.0060.00917.75
7.2.150.0060.01020.61
7.2.140.0070.00320.50
7.2.130.0060.00320.73
7.2.120.0170.01020.57
7.2.110.0070.01020.64
7.2.100.0030.01320.47
7.2.90.0000.01620.70
7.2.80.0240.00320.77
7.2.70.0030.01220.55
7.2.60.0270.00020.75
7.2.50.0030.01620.61
7.2.40.0030.01020.34
7.2.30.0110.00420.66
7.2.20.0070.01420.58
7.2.10.0070.01020.72
7.2.00.0070.00721.92
7.1.330.0050.01019.69
7.1.320.0110.00119.60
7.1.310.0050.01219.66
7.1.300.0050.01119.79
7.1.290.0080.00819.49
7.1.280.0100.00519.58
7.1.270.0060.00619.60
7.1.260.0150.00919.69
7.1.250.0100.00619.64
7.1.100.2650.01618.45
7.1.70.0230.00320.79
7.1.60.0100.01721.31
7.1.50.0040.02120.77
7.1.00.0030.07726.19
7.0.200.0200.00020.39
7.0.140.0100.07025.95
7.0.60.0100.08022.70
7.0.50.0030.04020.62
7.0.40.0170.07322.69
7.0.30.0400.07722.83
7.0.20.0300.08322.83
7.0.10.0100.04722.54
7.0.00.0130.07322.81
5.6.280.0100.08735.06
5.6.210.0130.09334.78
5.6.200.0070.10032.18
5.6.190.0130.05734.50
5.6.180.0130.09334.35
5.6.170.0330.07734.46
5.6.160.0070.07034.34
5.6.150.0070.10032.17
5.6.140.0030.10032.25
5.6.130.0070.05032.15
5.6.120.0100.06335.08
5.6.110.0170.07035.06
5.6.100.0100.09335.02
5.6.90.0130.08035.05
5.6.80.0200.08034.45
5.5.350.0070.09334.38
5.5.340.0170.09331.96
5.5.330.0070.05034.33
5.5.320.0330.08334.16
5.5.310.0270.06334.26
5.5.300.0070.04731.98
5.5.290.0070.09032.02
5.5.280.0170.09334.77
5.5.270.0070.08334.90
5.5.260.0230.05734.75
5.5.250.0200.09334.65
5.5.240.0100.07334.32
5.4.450.0230.04333.40
5.4.440.0670.05333.29
5.4.430.0170.06033.37
5.4.420.0400.06333.38
5.4.410.0200.07033.05
5.4.400.0130.07332.83
5.4.390.0200.06732.53
5.4.380.0200.07332.59
5.4.370.0200.07032.50
5.4.360.0300.05732.81
5.4.350.0130.07332.50
5.4.340.0200.06732.71
5.4.320.0110.05826.54
5.4.310.0110.04626.53
5.4.300.0110.05226.54
5.4.290.0130.05326.53
5.4.280.0070.05126.43
5.4.270.0040.05526.39
5.4.260.0090.06026.40
5.4.250.0090.04926.39
5.4.240.0100.04826.39
5.4.230.0070.05626.39
5.4.220.0110.05526.39
5.4.210.0060.05426.39
5.4.200.0100.05126.38
5.4.190.0100.05226.38
5.4.180.0160.06226.38
5.4.170.0070.05626.39
5.4.160.0110.04926.39
5.4.150.0110.04926.39
5.4.140.0190.05826.07
5.4.130.0130.05026.05
5.4.120.0130.05126.02
5.4.110.0100.05226.01
5.4.100.0100.05326.01
5.4.90.0140.05226.02
5.4.80.0140.04926.02
5.4.70.0090.05026.01
5.4.60.0140.04826.01
5.4.50.0100.05126.01
5.4.40.0160.05426.00
5.4.30.0140.05425.98
5.4.20.0140.04425.99
5.4.10.0150.04325.99
5.4.00.0160.04825.48
5.3.290.0180.05326.49
5.3.280.0140.04826.39
5.3.270.0130.06526.40
5.3.260.0150.06726.40
5.3.250.0170.07226.40
5.3.240.0180.04526.41
5.3.230.0090.05726.39
5.3.220.0110.05326.37
5.3.210.0090.05726.36
5.3.200.0120.06026.37
5.3.190.0100.05526.36
5.3.180.0170.06326.36
5.3.170.0100.06626.36
5.3.160.0160.05526.36
5.3.150.0100.05426.36
5.3.140.0140.04626.35
5.3.130.0130.04926.35
5.3.120.0140.05226.35
5.3.110.0080.05626.34
5.3.100.0170.06325.83
5.3.90.0130.06725.81
5.3.80.0190.05225.80
5.3.70.0110.04825.80
5.3.60.0150.05825.78
5.3.50.0150.05225.73
5.3.40.0120.05225.73
5.3.30.0140.05725.69
5.3.20.0110.06325.48
5.3.10.0120.05625.43
5.3.00.0080.05425.42
5.2.170.0070.04622.35
5.2.160.0080.04322.15
5.2.150.0070.05122.14
5.2.140.0100.04022.14
5.2.130.0090.04122.10
5.2.120.0110.04122.31
5.2.110.0110.05322.10
5.2.100.0170.04922.11
5.2.90.0110.05622.10
5.2.80.0140.05022.10
5.2.70.0070.04322.09
5.2.60.0080.04622.05
5.2.50.0090.05122.15
5.2.40.0100.05022.12
5.2.30.0130.04822.10
5.2.20.0120.04822.11
5.2.10.0120.03522.02
5.2.00.0090.03821.88
5.1.60.0080.04825.68
5.1.50.0180.04425.68
5.1.40.0190.04725.66
5.1.30.0080.05926.00
5.1.20.0150.05426.04
5.1.10.0180.04825.76
5.1.00.0160.05125.76
5.0.50.0080.0216.61
5.0.40.0130.0116.46
5.0.30.0070.0326.29
5.0.20.0020.0206.25
5.0.10.0050.0246.23
5.0.00.0050.0386.22
4.4.90.0040.0194.78
4.4.80.0020.0234.76
4.4.70.0040.0174.76
4.4.60.0020.0224.75
4.4.50.0040.0214.77
4.4.40.0020.0264.70
4.4.30.0060.0124.76
4.4.20.0020.0194.85
4.4.10.0030.0154.84
4.4.00.0020.0304.75
4.3.110.0020.0164.67
4.3.100.0020.0164.66
4.3.90.0050.0134.63
4.3.80.0020.0254.58
4.3.70.0010.0164.63
4.3.60.0030.0144.62
4.3.50.0030.0154.63
4.3.40.0010.0254.54
4.3.30.0030.0153.29
4.3.20.0030.0153.27
4.3.10.0030.0143.23
4.3.00.0000.02015.02

preferences:
45.72 ms | 401 KiB | 5 Q