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]; 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 "Move: $moves. Current: $currPos:$currItem"; } } 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.0090.00920.25
8.3.50.0150.00523.05
8.3.40.0120.00320.32
8.3.30.0120.00320.76
8.3.20.0040.00421.83
8.3.10.0000.00824.06
8.3.00.0070.00424.26
8.2.180.0100.01017.88
8.2.170.0130.00322.96
8.2.160.0110.00423.17
8.2.150.0060.00324.18
8.2.140.0030.00624.66
8.2.130.0030.01626.16
8.2.120.0060.00319.25
8.2.110.0090.00024.35
8.2.100.0090.00319.22
8.2.90.0040.00420.72
8.2.80.0060.00319.55
8.2.70.0070.00319.38
8.2.60.0000.00819.55
8.2.50.0060.00319.13
8.2.40.0060.00319.84
8.2.30.0000.00819.38
8.2.20.0040.00419.01
8.2.10.0040.00418.99
8.2.00.0090.00318.92
8.1.280.0140.00325.92
8.1.270.0000.00925.39
8.1.260.0030.00626.35
8.1.250.0060.00328.09
8.1.240.0090.00027.88
8.1.230.0060.00622.35
8.1.220.0000.00920.89
8.1.210.0060.00320.48
8.1.200.0110.00020.48
8.1.190.0060.00320.64
8.1.180.0060.00320.48
8.1.170.0100.00021.72
8.1.160.0040.00425.01
8.1.150.0040.00421.52
8.1.140.0000.00820.39
8.1.130.0030.00520.84
8.1.120.0080.00020.08
8.1.110.0030.00620.25
8.1.100.0060.00320.17
8.1.90.0030.00620.09
8.1.80.0000.00820.26
8.1.70.0040.00420.20
8.1.60.0000.00920.27
8.1.50.0000.00920.20
8.1.40.0100.00020.26
8.1.30.0070.00320.25
8.1.20.0070.00320.27
8.1.10.0040.00420.27
8.1.00.0030.00620.21
8.0.300.0040.00420.41
8.0.290.0100.00020.16
8.0.280.0060.00321.32
8.0.270.0000.00820.14
8.0.260.0070.00319.71
8.0.250.0030.00519.62
8.0.240.0030.00619.56
8.0.230.0000.00819.60
8.0.220.0080.00019.50
8.0.210.0060.00319.39
8.0.200.0000.00719.61
8.0.190.0040.00419.54
8.0.180.0030.00619.57
8.0.170.0040.00419.46
8.0.160.0060.00319.61
8.0.150.0030.00619.48
8.0.140.0080.00019.39
8.0.130.0000.00716.03
8.0.120.0050.00519.40
8.0.110.0030.00619.52
8.0.100.0040.00419.39
8.0.90.0090.00019.36
8.0.80.0100.01319.46
8.0.70.0030.00619.61
8.0.60.0060.00319.59
8.0.50.0080.00019.36
8.0.30.0130.01319.74
8.0.20.0100.01520.01
8.0.10.0040.00419.48
8.0.00.0130.00819.46
7.4.330.0050.00018.89
7.4.320.0000.00719.18
7.4.300.0050.00219.09
7.4.290.0110.00019.01
7.4.280.0000.00919.16
7.4.270.0000.00819.09
7.4.260.0030.00619.06
7.4.250.0000.00919.05
7.4.240.0010.00719.09
7.4.230.0080.00019.30
7.4.220.0150.00619.12
7.4.210.0130.00819.17
7.4.200.0040.00419.25
7.4.190.0080.00019.25
7.4.160.0130.01019.05
7.4.150.0150.00619.20
7.4.140.0140.01019.10
7.4.130.0120.00919.12
7.4.120.0110.01119.14
7.4.110.0240.00019.03
7.4.100.0130.00619.31
7.4.90.0130.01118.92
7.4.80.0160.01019.39
7.4.70.0100.01419.13
7.4.60.0130.00719.17
7.4.50.0030.00718.88
7.4.40.0060.00922.77
7.4.30.0150.00419.14
7.4.00.0060.01317.48
7.3.330.0000.00615.87
7.3.320.0000.00616.08
7.3.310.0060.00318.91
7.3.300.0050.00318.86
7.3.290.0170.00418.91
7.3.280.0080.01318.94
7.3.270.0100.01019.08
7.3.260.0070.01318.93
7.3.250.0140.00919.13
7.3.240.0120.00919.18
7.3.230.0160.00319.05
7.3.210.0070.01319.00
7.3.200.0060.01419.39
7.3.190.0160.00618.98
7.3.180.0150.00418.93
7.3.170.0140.00318.87
7.3.160.0040.01519.17
7.3.120.0070.00717.64
7.2.330.0110.01119.22
7.2.320.0130.00819.10
7.2.310.0090.01219.27
7.2.300.0150.00619.01
7.2.290.0140.00719.30
7.2.00.0000.01322.83
7.1.200.0110.00419.52
7.1.100.0800.01418.96
7.1.70.0230.00420.84
7.1.60.0070.02120.95
7.1.50.0040.02220.83
7.1.00.0100.07326.36
7.0.200.0120.01220.63
7.0.140.0030.07726.09
7.0.60.0070.07722.81
7.0.50.0130.08020.63
7.0.40.0170.05022.73
7.0.30.0430.07322.75
7.0.20.0430.08322.55
7.0.10.0070.08022.59
7.0.00.0230.07022.66
5.6.280.0130.08335.15
5.6.210.0270.08034.59
5.6.200.0170.04032.03
5.6.190.0170.09334.34
5.6.180.0200.08334.26
5.6.170.0200.06734.36
5.6.160.0170.08734.46
5.6.150.0170.04332.22
5.6.140.0000.06032.16
5.6.130.0170.06032.15
5.6.120.0100.04735.03
5.6.110.0200.05335.02
5.6.100.0170.08035.03
5.6.90.0130.04335.04
5.6.80.0070.10334.55
5.5.350.0200.08734.56
5.5.340.0170.08732.00
5.5.330.0130.09334.19
5.5.320.0470.07733.97
5.5.310.0270.04734.26
5.5.300.0200.05331.93
5.5.290.0170.08331.98
5.5.280.0070.09334.73
5.5.270.0170.08334.79
5.5.260.0200.03734.88
5.5.250.0070.10034.53
5.5.240.0100.08734.07
5.4.450.0230.05333.38
5.4.440.0430.04733.54
5.4.430.0300.06333.31
5.4.420.0570.04733.42
5.4.410.0270.06033.04
5.4.400.0170.07332.54
5.4.390.0230.06732.57
5.4.380.0270.06332.59
5.4.370.0330.05332.74
5.4.360.0170.07332.60
5.4.350.0430.04732.77
5.4.340.0270.06732.61
5.4.320.0150.04726.54
5.4.310.0170.04826.53
5.4.300.0150.04926.54
5.4.290.0090.05026.53
5.4.280.0080.04826.43
5.4.270.0120.04726.39
5.4.260.0080.05126.39
5.4.250.0110.04626.39
5.4.240.0100.05126.39
5.4.230.0080.05526.39
5.4.220.0160.04626.39
5.4.210.0080.05226.39
5.4.200.0120.04626.38
5.4.190.0100.04726.39
5.4.180.0110.04626.38
5.4.170.0140.04326.39
5.4.160.0110.05026.39
5.4.150.0090.04626.39
5.4.140.0100.05526.07
5.4.130.0120.05626.06
5.4.120.0130.05126.01
5.4.110.0160.06026.01
5.4.100.0070.04926.02
5.4.90.0120.04626.02
5.4.80.0160.04526.02
5.4.70.0090.05226.01
5.4.60.0100.04726.01
5.4.50.0080.05026.00
5.4.40.0090.05226.00
5.4.30.0120.04325.99
5.4.20.0140.04625.99
5.4.10.0100.04525.99
5.4.00.0130.04725.48
5.3.290.0140.04926.49
5.3.280.0130.04726.39
5.3.270.0090.05626.40
5.3.260.0100.05926.40
5.3.250.0100.04726.40
5.3.240.0070.05126.40
5.3.230.0090.04826.39
5.3.220.0110.05126.37
5.3.210.0110.04926.37
5.3.200.0090.04726.36
5.3.190.0140.06426.36
5.3.180.0070.05026.36
5.3.170.0110.06226.36
5.3.160.0090.06126.36
5.3.150.0150.06126.36
5.3.140.0140.06526.35
5.3.130.0180.05826.34
5.3.120.0090.05426.34
5.3.110.0130.04526.34
5.3.100.0100.05425.83
5.3.90.0090.07225.81
5.3.80.0080.05325.80
5.3.70.0100.05025.80
5.3.60.0090.04925.79
5.3.50.0140.04825.73
5.3.40.0130.04325.73
5.3.30.0060.05025.69
5.3.20.0110.04625.47
5.3.10.0100.04525.44
5.3.00.0090.04825.43
5.2.170.0130.03822.14
5.2.160.0080.04422.14
5.2.150.0130.04222.14
5.2.140.0100.05122.14
5.2.130.0110.04322.10
5.2.120.0080.04722.09
5.2.110.0070.04122.10
5.2.100.0070.04122.11
5.2.90.0070.04122.10
5.2.80.0070.04222.10
5.2.70.0090.04622.09
5.2.60.0060.04522.05
5.2.50.0040.05422.14
5.2.40.0090.04722.12
5.2.30.0130.06722.10
5.2.20.0070.05322.11
5.2.10.0090.04322.02
5.2.00.0120.03921.87
5.1.60.0060.04625.68
5.1.50.0170.06525.68
5.1.40.0120.03925.66
5.1.30.0120.03826.01
5.1.20.0120.04026.04
5.1.10.0080.04325.77
5.1.00.0170.05525.76
5.0.50.0040.0226.62
5.0.40.0050.0206.46
5.0.30.0070.0366.29
5.0.20.0050.0266.25
5.0.10.0040.0206.23
5.0.00.0060.0296.22
4.4.90.0030.0154.78
4.4.80.0020.0174.75
4.4.70.0040.0144.76
4.4.60.0030.0154.75
4.4.50.0040.0184.77
4.4.40.0050.0224.71
4.4.30.0040.0174.76
4.4.20.0030.0174.84
4.4.10.0040.0154.85
4.4.00.0040.0304.76
4.3.110.0080.0224.67
4.3.100.0010.0194.67
4.3.90.0020.0164.63
4.3.80.0040.0234.59
4.3.70.0030.0154.63
4.3.60.0060.0134.63
4.3.50.0010.0174.63
4.3.40.0030.0254.53
4.3.30.0030.0203.29
4.3.20.0030.0193.27
4.3.10.0020.0203.23
4.3.00.0030.01715.02

preferences:
45.86 ms | 401 KiB | 5 Q