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) { $topBoundry = $currPos; $currPos -= floor(($currPos+$bottomBoundry)/2); $moves++; } else if ($currItem < $needle) { $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.0160.00020.13
8.3.50.0100.00723.04
8.3.40.0130.00320.16
8.3.30.0090.00620.70
8.3.20.0060.00321.79
8.3.10.0030.00624.04
8.3.00.0110.00022.08
8.2.180.0130.00718.13
8.2.170.0090.00622.96
8.2.160.0040.01123.02
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0160.00326.16
8.2.120.0060.00319.13
8.2.110.0070.00324.38
8.2.100.0120.00319.53
8.2.90.0080.00020.80
8.2.80.0060.00319.64
8.2.70.0000.00919.25
8.2.60.0040.00419.43
8.2.50.0060.00619.13
8.2.40.0030.00719.78
8.2.30.0080.00019.27
8.2.20.0040.00418.90
8.2.10.0040.00421.00
8.2.00.0000.01019.04
8.1.280.0140.00725.92
8.1.270.0030.00625.39
8.1.260.0050.00526.35
8.1.250.0030.00528.09
8.1.240.0090.00028.16
8.1.230.0070.00722.33
8.1.220.0000.00920.68
8.1.210.0060.00320.61
8.1.200.0070.00320.47
8.1.190.0060.00320.65
8.1.180.0090.00020.25
8.1.170.0060.00321.75
8.1.160.0060.00325.01
8.1.150.0030.00621.51
8.1.140.0080.00020.32
8.1.130.0030.00520.82
8.1.120.0040.00420.13
8.1.110.0070.00320.25
8.1.100.0080.00020.23
8.1.90.0030.00620.23
8.1.80.0030.00620.24
8.1.70.0040.00420.11
8.1.60.0000.01020.30
8.1.50.0030.00620.20
8.1.40.0030.00720.20
8.1.30.0100.00020.25
8.1.20.0050.00520.36
8.1.10.0060.00320.34
8.1.00.0030.00620.11
8.0.300.0060.00320.35
8.0.290.0060.00320.16
8.0.280.0030.00521.32
8.0.270.0040.00420.13
8.0.260.0040.00819.60
8.0.250.0050.00319.48
8.0.240.0050.00319.49
8.0.230.0040.00419.60
8.0.220.0040.00419.52
8.0.210.0060.00319.51
8.0.200.0070.00019.63
8.0.190.0060.00319.42
8.0.180.0060.00319.56
8.0.170.0070.00319.58
8.0.160.0030.00619.60
8.0.150.0000.00919.45
8.0.140.0040.00419.39
8.0.130.0030.00316.03
8.0.120.0030.00619.54
8.0.110.0080.00019.56
8.0.100.0000.00919.43
8.0.90.0080.00019.34
8.0.80.0130.00619.52
8.0.70.0060.00319.74
8.0.60.0030.00619.44
8.0.50.0080.00019.47
8.0.30.0130.00919.64
8.0.20.0130.01619.58
8.0.10.0060.00319.57
8.0.00.0130.01019.33
7.4.330.0000.00518.78
7.4.320.0070.00019.15
7.4.300.0050.00219.24
7.4.290.0080.00319.06
7.4.280.0040.00419.17
7.4.270.0060.00319.07
7.4.260.0000.00919.09
7.4.250.0050.00519.16
7.4.240.0020.00619.14
7.4.230.0040.00419.26
7.4.220.0140.00719.11
7.4.210.0090.01119.25
7.4.200.0030.00619.21
7.4.190.0040.00419.07
7.4.160.0080.01119.16
7.4.150.0090.01319.03
7.4.140.0130.01019.09
7.4.130.0160.00519.11
7.4.120.0150.00519.12
7.4.110.0070.01419.04
7.4.100.0100.01019.21
7.4.90.0110.00919.32
7.4.80.0120.00919.39
7.4.70.0070.01519.03
7.4.60.0160.00319.02
7.4.50.0030.00619.21
7.4.40.0040.01122.77
7.4.30.0110.00719.21
7.4.00.0040.01417.71
7.3.330.0060.00015.82
7.3.320.0030.00315.85
7.3.310.0060.00318.91
7.3.300.0030.00518.93
7.3.290.0090.00818.85
7.3.280.0100.00918.87
7.3.270.0140.00719.20
7.3.260.0170.00319.10
7.3.250.0160.01018.89
7.3.240.0100.01019.15
7.3.230.0110.00818.92
7.3.210.0140.00718.95
7.3.200.0100.01019.39
7.3.190.0180.00718.82
7.3.180.0210.00018.90
7.3.170.0100.01018.95
7.3.160.0160.00419.05
7.3.120.0100.01017.44
7.2.330.0180.00319.12
7.2.320.0110.00919.32
7.2.310.0150.00619.10
7.2.300.0100.01319.07
7.2.290.0060.01619.39
7.2.60.0110.01120.76
7.2.00.0140.00323.04
7.1.200.0060.00619.52
7.1.100.1630.01318.76
7.1.70.0190.00620.90
7.1.60.0100.01720.98
7.1.50.0030.02220.83
7.1.00.0100.07026.26
7.0.200.0180.00420.63
7.0.140.0030.07025.99
7.0.60.0070.08322.71
7.0.50.0130.07320.62
7.0.40.0100.06322.70
7.0.30.0270.04722.75
7.0.20.0330.07722.54
7.0.10.0130.08022.82
7.0.00.0070.08722.64
5.6.280.0130.08334.82
5.6.210.0070.07034.72
5.6.200.0200.09032.22
5.6.190.0200.06334.36
5.6.180.0130.06334.53
5.6.170.0430.07034.37
5.6.160.0130.09334.36
5.6.150.0030.10332.17
5.6.140.0100.04332.19
5.6.130.0100.09032.26
5.6.120.0200.05035.05
5.6.110.0200.04735.04
5.6.100.0230.08335.14
5.6.90.0070.05035.07
5.6.80.0130.07734.55
5.5.350.0370.09334.36
5.5.340.0030.05331.98
5.5.330.0270.08734.21
5.5.320.0370.08734.07
5.5.310.0200.07334.28
5.5.300.0070.05032.00
5.5.290.0230.05732.00
5.5.280.0070.07734.93
5.5.270.0070.05034.80
5.5.260.0200.08734.66
5.5.250.0130.10034.65
5.5.240.0070.05034.32
5.4.450.0430.05333.39
5.4.440.0600.05733.35
5.4.430.0770.05733.38
5.4.420.0400.05333.39
5.4.410.0200.06033.04
5.4.400.0170.07032.77
5.4.390.0270.05732.62
5.4.380.0200.07332.79
5.4.370.0230.06332.59
5.4.360.0330.05732.62
5.4.350.0170.07332.73
5.4.340.0270.06332.79
5.4.320.0070.04926.54
5.4.310.0100.04926.53
5.4.300.0140.04226.54
5.4.290.0240.06226.53
5.4.280.0090.05726.43
5.4.270.0100.04726.39
5.4.260.0090.05026.39
5.4.250.0090.05526.40
5.4.240.0100.05426.40
5.4.230.0100.04826.38
5.4.220.0080.04826.39
5.4.210.0110.04426.39
5.4.200.0210.05026.39
5.4.190.0080.04926.38
5.4.180.0130.04526.38
5.4.170.0080.04926.39
5.4.160.0070.05326.39
5.4.150.0090.04826.39
5.4.140.0190.04626.07
5.4.130.0070.05126.05
5.4.120.0080.04826.02
5.4.110.0090.04626.01
5.4.100.0120.04426.01
5.4.90.0080.05226.01
5.4.80.0080.05226.01
5.4.70.0090.04726.01
5.4.60.0120.04626.01
5.4.50.0160.05226.00
5.4.40.0100.04825.99
5.4.30.0090.04825.99
5.4.20.0100.05025.99
5.4.10.0080.05025.99
5.4.00.0130.04725.48
5.3.290.0150.05026.49
5.3.280.0110.05526.39
5.3.270.0170.04326.40
5.3.260.0100.05126.40
5.3.250.0100.04926.40
5.3.240.0090.04826.41
5.3.230.0090.05026.39
5.3.220.0110.05126.36
5.3.210.0100.05126.36
5.3.200.0160.05426.36
5.3.190.0110.05426.36
5.3.180.0100.04826.36
5.3.170.0120.04826.36
5.3.160.0100.04826.36
5.3.150.0120.04726.36
5.3.140.0160.04326.35
5.3.130.0080.05326.34
5.3.120.0120.04926.34
5.3.110.0180.04426.34
5.3.100.0200.04225.83
5.3.90.0080.04825.81
5.3.80.0090.04825.80
5.3.70.0080.05125.80
5.3.60.0050.05025.78
5.3.50.0060.05025.73
5.3.40.0080.04925.73
5.3.30.0100.04525.70
5.3.20.0080.04725.48
5.3.10.0120.04425.43
5.3.00.0070.04925.42
5.2.170.0120.03722.14
5.2.160.0050.04222.15
5.2.150.0070.04122.14
5.2.140.0100.03922.14
5.2.130.0070.04022.10
5.2.120.0080.03922.11
5.2.110.0090.03922.10
5.2.100.0090.03722.11
5.2.90.0060.04222.11
5.2.80.0100.03822.10
5.2.70.0070.04222.09
5.2.60.0090.03922.05
5.2.50.0060.05022.16
5.2.40.0080.04722.13
5.2.30.0100.04622.11
5.2.20.0070.04822.11
5.2.10.0070.03722.02
5.2.00.0080.03621.88
5.1.60.0080.03725.69
5.1.50.0090.03725.69
5.1.40.0120.03325.67
5.1.30.0080.03926.01
5.1.20.0070.04126.04
5.1.10.0100.03725.77
5.1.00.0110.03425.76
5.0.50.0060.0186.61
5.0.40.0030.0206.47
5.0.30.0030.0316.29
5.0.20.0040.0186.25
5.0.10.0060.0176.23
5.0.00.0010.0366.22
4.4.90.0000.0194.78
4.4.80.0030.0154.75
4.4.70.0040.0154.76
4.4.60.0010.0174.75
4.4.50.0030.0154.77
4.4.40.0060.0304.71
4.4.30.0010.0174.76
4.4.20.0010.0174.84
4.4.10.0040.0164.85
4.4.00.0030.0244.76
4.3.110.0020.0174.67
4.3.100.0020.0154.66
4.3.90.0010.0164.63
4.3.80.0030.0244.58
4.3.70.0030.0144.63
4.3.60.0040.0134.63
4.3.50.0040.0144.63
4.3.40.0020.0244.54
4.3.30.0020.0163.29
4.3.20.0010.0173.27
4.3.10.0020.0163.24
4.3.00.0000.01315.02

preferences:
52.27 ms | 401 KiB | 5 Q