3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = range(1,1000000); //Million 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.0150.00734.30
8.3.50.0220.00832.61
8.3.40.0240.01034.09
8.3.30.0250.00334.59
8.3.20.0120.00435.29
8.3.10.0070.00337.39
8.3.00.0090.00937.74
8.2.180.0270.01031.50
8.2.170.0170.01734.18
8.2.160.0040.01436.40
8.2.150.0120.00434.27
8.2.140.0130.00334.47
8.2.130.0080.00835.90
8.2.120.0130.00333.13
8.2.110.0060.01037.79
8.2.100.0110.01133.28
8.2.90.0110.00434.59
8.2.80.0070.01132.88
8.2.70.0070.01032.87
8.2.60.0070.00733.30
8.2.50.0040.01133.00
8.2.40.0100.00733.40
8.2.30.0100.00733.35
8.2.20.0140.00032.95
8.2.10.0070.00734.60
8.2.00.0130.00732.86
8.1.280.0350.01646.75
8.1.270.0040.00423.79
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00320.78
8.1.230.0110.00017.42
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0090.00017.13
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0040.00418.53
8.1.160.0000.00822.03
8.1.150.0070.00018.50
8.1.140.0000.00717.32
8.1.130.0030.00317.70
8.1.120.0000.00817.26
8.1.110.0040.00417.36
8.1.100.0000.00717.34
8.1.90.0060.00317.36
8.1.80.0050.00317.38
8.1.70.0030.00617.26
8.1.60.0000.00817.38
8.1.50.0000.00817.48
8.1.40.0030.00517.40
8.1.30.0030.00717.61
8.1.20.0000.00917.46
8.1.10.0200.00047.87
8.1.00.0070.01347.75
8.0.300.0150.00647.16
8.0.290.0170.00747.25
8.0.280.0220.00448.64
8.0.270.0140.01047.46
8.0.260.0260.00346.94
8.0.250.0120.00647.23
8.0.240.0070.01147.28
8.0.230.0060.01247.22
8.0.220.0170.00047.07
8.0.210.0180.00047.04
8.0.200.0190.00647.21
8.0.190.0070.01347.15
8.0.180.0140.00747.06
8.0.170.0190.00347.15
8.0.160.0170.00347.21
8.0.150.0100.01047.20
8.0.140.0200.00347.12
8.0.130.0180.00743.68
8.0.120.0120.00947.09
8.0.110.0120.00646.94
8.0.100.0120.00847.01
8.0.90.0040.01447.15
8.0.80.0290.01647.16
8.0.70.0070.01147.03
8.0.60.0150.00447.03
8.0.50.0130.00647.05
8.0.30.0320.01847.30
8.0.20.0380.01947.26
8.0.10.0190.00047.25
8.0.00.0350.01346.93
7.4.330.0130.00745.28
7.4.320.0130.00346.78
7.4.300.0130.01046.69
7.4.290.0210.00346.70
7.4.280.0230.00846.63
7.4.270.0130.00646.71
7.4.260.0150.00446.68
7.4.250.0140.00746.77
7.4.240.0120.00846.78
7.4.230.0140.00446.59
7.4.220.0340.01546.80
7.4.210.0280.01346.81
7.4.200.0130.00646.90
7.4.190.0160.00346.97
7.4.160.0310.01446.57
7.4.150.0350.01446.61
7.4.140.0420.01346.59
7.4.130.0390.01646.70
7.4.120.0360.01246.75
7.4.110.0370.02346.90
7.4.100.0310.01646.67
7.4.90.0390.01946.77
7.4.80.0300.02046.78
7.4.70.0290.02946.84
7.4.60.0490.00346.64
7.4.50.0070.00746.71
7.4.40.0230.00546.46
7.4.30.0410.00646.76
7.4.00.0260.00745.38
7.3.330.0060.00943.45
7.3.320.0110.00743.57
7.3.310.0090.00946.36
7.3.300.0100.00746.45
7.3.290.0300.01246.54
7.3.280.0380.01746.51
7.3.270.0430.00646.48
7.3.260.0460.01346.56
7.3.250.0430.01846.76
7.3.240.0320.01646.57
7.3.230.0490.00046.52
7.3.210.0340.01446.55
7.3.200.0350.02546.64
7.3.190.0340.01446.77
7.3.180.0410.01046.55
7.3.170.0300.01846.76
7.3.160.0290.01646.61
7.3.120.0240.01444.89
7.2.330.0390.01046.57
7.2.320.0350.01646.86
7.2.310.0360.01346.99
7.2.300.0320.01946.53
7.2.290.0460.01546.53
7.2.60.1840.01048.67
7.2.00.0800.01051.30
7.1.200.0640.01747.62
7.1.100.1080.01445.93
7.1.70.0370.02048.88
7.1.60.0170.02749.31
7.1.50.0130.02948.80
7.1.00.0200.07354.22
7.0.200.2780.02047.00
7.0.140.0100.08054.09
7.0.60.0270.08750.34
7.0.50.0200.08748.25
7.0.40.0300.08750.30
7.0.30.0670.06050.11
7.0.20.0800.07350.39
7.0.10.0230.09350.34
7.0.00.0200.05750.22
5.6.280.0270.11385.46
5.6.210.0270.12385.35
5.6.200.0100.10082.88
5.6.190.0300.12785.01
5.6.180.0300.11785.03
5.6.170.0470.08785.03
5.6.160.0230.10085.06
5.6.150.0100.08782.86
5.6.140.0230.09782.63
5.6.130.0100.07782.77
5.6.120.0530.09085.76
5.6.110.0300.06385.66
5.6.100.0200.12085.62
5.6.90.0370.13085.64
5.6.80.0500.09785.16
5.5.350.0170.08085.02
5.5.340.0300.12082.61
5.5.330.0300.08084.66
5.5.320.0470.08084.88
5.5.310.0370.07784.89
5.5.300.0300.09382.42
5.5.290.0270.08782.59
5.5.280.0330.07385.51
5.5.270.0330.10085.48
5.5.260.0330.12085.52
5.5.250.0270.09085.25
5.5.240.0300.10084.77
5.4.450.1170.12084.05
5.4.440.1130.09784.24
5.4.430.0630.08383.81
5.4.420.0430.10783.98
5.4.410.0500.10383.71
5.4.400.1270.11083.46
5.4.390.1870.10383.44
5.4.380.0530.10783.30
5.4.370.0400.08083.44
5.4.360.0400.11383.30
5.4.350.0230.07676.73
5.4.340.0230.06776.73
5.4.320.0240.06677.22
5.4.310.0270.06477.21
5.4.300.0230.06777.22
5.4.290.0200.07077.21
5.4.280.0220.08177.11
5.4.270.0200.07477.07
5.4.260.0220.07377.08
5.4.250.0230.07177.07
5.4.240.0240.07277.07
5.4.230.0350.07677.07
5.4.220.0180.07677.07
5.4.210.0290.07077.07
5.4.200.0270.06977.07
5.4.190.0210.07877.06
5.4.180.0210.07977.05
5.4.170.0220.07577.07
5.4.160.0210.08977.07
5.4.150.0210.07177.06
5.4.140.0270.06976.75
5.4.130.0270.07476.74
5.4.120.0270.06576.70
5.4.110.0250.07176.70
5.4.100.0230.07376.69
5.4.90.0220.07376.69
5.4.80.0290.07176.69
5.4.70.0260.07476.69
5.4.60.0220.08176.69
5.4.50.0230.06876.68
5.4.40.0170.07276.68
5.4.30.0290.06876.66
5.4.20.0340.10076.67
5.4.10.0370.09576.67
5.4.00.0260.09476.16
5.3.290.0250.06676.11
5.3.280.0290.07876.01
5.3.270.0330.08276.02
5.3.260.0260.07576.02
5.3.250.0210.07276.02
5.3.240.0270.07476.02
5.3.230.0220.06976.02
5.3.220.0320.06675.98
5.3.210.0200.07575.98
5.3.200.0260.06875.98
5.3.190.0230.07075.98
5.3.180.0170.08475.98
5.3.170.0290.06375.98
5.3.160.0250.06975.97
5.3.150.0230.07075.98
5.3.140.0170.08775.97
5.3.130.0190.07875.96
5.3.120.0210.08475.96
5.3.110.0220.07775.96
5.3.100.0240.08675.45
5.3.90.0430.08875.43
5.3.80.0350.07575.41
5.3.70.0170.07975.42
5.3.60.0220.07275.40
5.3.50.0270.08775.35
5.3.40.0280.08475.35
5.3.30.0280.07275.31
5.3.20.0150.08075.10
5.3.10.0230.07175.67
5.3.00.0310.07075.04
5.2.170.0210.06673.05
5.2.160.0260.07973.05
5.2.150.0180.06973.05
5.2.140.0290.06273.67
5.2.130.0270.08073.00
5.2.120.0210.06773.01
5.2.110.0200.07573.01
5.2.100.0230.06573.02
5.2.90.0220.07173.01
5.2.80.0180.08473.00
5.2.70.0330.08772.99
5.2.60.0290.09272.95
5.2.50.0320.14072.94
5.2.40.0290.10372.91
5.2.30.0280.11672.63
5.2.20.0240.08772.63
5.2.10.0260.05772.54
5.2.00.0400.114138.65
5.1.60.0650.154183.79
5.1.50.0490.158183.78
5.1.40.0450.160183.77
5.1.30.0550.168184.11
5.1.20.0450.153184.13
5.1.10.0480.148183.86
5.1.00.0500.159183.86
5.0.50.0040.0236.61
5.0.40.0040.0206.47
5.0.30.0050.0356.29
5.0.20.0040.0196.25
5.0.10.0050.0196.23
5.0.00.0060.0296.22
4.4.90.0020.0174.78
4.4.80.0050.0154.75
4.4.70.0030.0164.75
4.4.60.0010.0204.76
4.4.50.0030.0194.77
4.4.40.0040.0254.71
4.4.30.0040.0174.76
4.4.20.0070.0124.84
4.4.10.0030.0214.85
4.4.00.0030.0264.76
4.3.110.0040.0154.66
4.3.100.0030.0154.66
4.3.90.0040.0154.64
4.3.80.0040.0254.58
4.3.70.0030.0154.63
4.3.60.0050.0134.63
4.3.50.0060.0124.62
4.3.40.0060.0214.54
4.3.30.0030.0163.29
4.3.20.0020.0223.27
4.3.10.0000.0173.23
4.3.00.0000.0236.95

preferences:
36.71 ms | 401 KiB | 5 Q