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) { $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.00320.36
8.3.50.0100.00923.08
8.3.40.0080.00820.23
8.3.30.0110.00720.57
8.3.20.0080.00021.94
8.3.10.0040.00423.97
8.3.00.0060.00623.93
8.2.180.0120.00617.98
8.2.170.0160.00022.96
8.2.160.0070.00723.12
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0140.00726.16
8.2.120.0060.00319.38
8.2.110.0000.01024.35
8.2.100.0070.00619.22
8.2.90.0060.00320.67
8.2.80.0000.00919.51
8.2.70.0000.00919.25
8.2.60.0040.00419.43
8.2.50.0060.00319.25
8.2.40.0070.00319.66
8.2.30.0040.00419.42
8.2.20.0080.00018.87
8.2.10.0040.00418.98
8.2.00.0030.00719.05
8.1.280.0030.01425.92
8.1.270.0060.00325.39
8.1.260.0050.00526.35
8.1.250.0060.00328.09
8.1.240.0060.00327.92
8.1.230.0100.00322.36
8.1.220.0030.00620.80
8.1.210.0090.00020.48
8.1.200.0030.00720.60
8.1.190.0000.00920.76
8.1.180.0060.00320.36
8.1.170.0040.00721.73
8.1.160.0000.00925.14
8.1.150.0030.00621.55
8.1.140.0030.00620.31
8.1.130.0040.00420.75
8.1.120.0030.00620.21
8.1.110.0030.00620.16
8.1.100.0060.00320.23
8.1.90.0030.00620.11
8.1.80.0080.00020.17
8.1.70.0030.00620.25
8.1.60.0070.00320.38
8.1.50.0000.00920.30
8.1.40.0080.00420.29
8.1.30.0000.00920.40
8.1.20.0060.00320.37
8.1.10.0100.00020.28
8.1.00.0090.00020.27
8.0.300.0040.00420.35
8.0.290.0100.00020.30
8.0.280.0080.00021.29
8.0.270.0040.00420.02
8.0.260.0110.00019.70
8.0.250.0030.00519.46
8.0.240.0080.00019.52
8.0.230.0040.00419.60
8.0.220.0030.00619.55
8.0.210.0040.00419.55
8.0.200.0030.00519.62
8.0.190.0040.00419.53
8.0.180.0090.00019.44
8.0.170.0060.00319.50
8.0.160.0090.00019.44
8.0.150.0000.00819.50
8.0.140.0000.00919.53
8.0.130.0040.00316.04
8.0.120.0030.00619.56
8.0.110.0100.00019.44
8.0.100.0090.00019.34
8.0.90.0090.00019.50
8.0.80.0140.00719.55
8.0.70.0080.00019.48
8.0.60.0000.00919.55
8.0.50.0040.00419.44
8.0.30.0130.00919.56
8.0.20.0130.01219.72
8.0.10.0060.00319.64
8.0.00.0150.00519.21
7.4.330.0060.00019.02
7.4.320.0080.00019.11
7.4.300.0000.00719.11
7.4.290.0000.01119.13
7.4.280.0000.00919.08
7.4.270.0030.00519.03
7.4.260.0050.00319.07
7.4.250.0030.00619.04
7.4.240.0060.00319.16
7.4.230.0080.00019.19
7.4.220.0120.00919.14
7.4.210.0130.00619.14
7.4.200.0060.00319.17
7.4.190.0060.00319.32
7.4.160.0130.00619.05
7.4.150.0150.00718.99
7.4.140.0170.00719.09
7.4.130.0100.01319.11
7.4.120.0110.01119.12
7.4.110.0120.00919.15
7.4.100.0140.00719.23
7.4.90.0130.00819.14
7.4.80.0160.00619.39
7.4.70.0110.01318.92
7.4.60.0150.00619.02
7.4.50.0070.00319.01
7.4.40.0110.00722.77
7.4.30.0170.00419.18
7.4.00.0070.01017.18
7.3.330.0060.00016.04
7.3.320.0000.00616.01
7.3.310.0090.00018.89
7.3.300.0040.00418.89
7.3.290.0200.00018.86
7.3.280.0140.00818.90
7.3.270.0180.00918.91
7.3.260.0100.01018.95
7.3.250.0180.00418.96
7.3.240.0160.00619.02
7.3.230.0130.00719.18
7.3.210.0180.00419.00
7.3.200.0140.01619.39
7.3.190.0080.01619.09
7.3.180.0120.00618.88
7.3.170.0090.00919.11
7.3.160.0070.01118.82
7.3.120.0060.00917.36
7.3.10.0290.00920.27
7.3.00.0240.01020.08
7.2.330.0100.01419.30
7.2.320.0100.01019.09
7.2.310.0160.00319.05
7.2.300.0180.00719.27
7.2.290.0140.01119.23
7.2.130.0180.00720.07
7.2.120.0160.00920.16
7.2.110.0260.01020.59
7.2.100.0070.01420.05
7.2.90.0270.01520.41
7.2.80.0270.00720.31
7.2.70.0240.00620.23
7.2.60.0140.01420.53
7.2.50.0180.00720.26
7.2.40.0200.00820.39
7.2.30.0210.01720.52
7.2.20.0280.00320.08
7.2.10.0300.01320.27
7.2.00.0080.01321.65
7.1.250.0280.00319.55
7.1.200.0060.00619.65
7.1.100.1750.01018.56
7.1.70.0180.00720.71
7.1.60.0180.00621.22
7.1.50.0030.02320.53
7.1.00.0030.07726.20
7.0.200.0160.00420.61
7.0.140.0000.07726.21
7.0.60.0100.06722.76
7.0.50.0030.04320.64
7.0.40.0130.07022.51
7.0.30.0700.06322.78
7.0.20.0270.07722.64
7.0.10.0330.06322.62
7.0.00.0030.04322.70
5.6.280.0030.09335.07
5.6.210.0170.07734.73
5.6.200.0070.10732.18
5.6.190.0070.05734.38
5.6.180.0200.10734.38
5.6.170.0370.08734.37
5.6.160.0200.08334.34
5.6.150.0100.04732.17
5.6.140.0130.06732.14
5.6.130.0070.10032.23
5.6.120.0130.10335.18
5.6.110.0070.10735.05
5.6.100.0170.07035.14
5.6.90.0100.09035.11
5.6.80.0130.06734.57
5.6.70.3200.04334.43
5.5.350.0170.09334.56
5.5.340.0170.08332.03
5.5.330.0000.05734.23
5.5.320.0270.04334.17
5.5.310.0300.09334.28
5.5.300.0130.05732.07
5.5.290.0070.10031.83
5.5.280.0100.10335.00
5.5.270.0170.04734.93
5.5.260.0170.05734.83
5.5.250.0000.05334.83
5.5.240.0070.07034.30
5.4.450.1070.09333.16
5.4.440.0630.10333.44
5.4.430.0130.09033.51
5.4.420.0170.07333.50
5.4.410.0170.07332.73
5.4.400.0400.06732.87
5.4.390.0200.06732.75
5.4.380.0130.08032.62
5.4.370.0170.04332.72
5.4.360.0130.05032.61
5.4.350.0170.05526.05
5.4.340.0110.04626.05
5.4.320.0080.05226.54
5.4.310.0010.05726.53
5.4.300.0070.04826.54
5.4.290.0100.04926.54
5.4.280.0100.04626.43
5.4.270.0040.05326.39
5.4.260.0120.04926.39
5.4.250.0130.04826.39
5.4.240.0060.05226.39
5.4.230.0100.04826.38
5.4.220.0090.04626.38
5.4.210.0100.04626.39
5.4.200.0120.04826.38
5.4.190.0120.04526.38
5.4.180.0090.04926.38
5.4.170.0110.05026.39
5.4.160.0120.04326.39
5.4.150.0090.04626.39
5.4.140.0120.04926.07
5.4.130.0100.04926.06
5.4.120.0100.04726.02
5.4.110.0120.04726.02
5.4.100.0110.04526.02
5.4.90.0120.04526.01
5.4.80.0110.05226.01
5.4.70.0110.05026.00
5.4.60.0080.04726.01
5.4.50.0150.04626.00
5.4.40.0120.04225.99
5.4.30.0150.04725.99
5.4.20.0100.04525.99
5.4.10.0050.04925.99
5.4.00.0060.04925.48
5.3.290.0100.05126.49
5.3.280.0060.05126.39
5.3.270.0080.05326.40
5.3.260.0120.04826.40
5.3.250.0160.05326.40
5.3.240.0150.04226.40
5.3.230.0090.05026.39
5.3.220.0090.04926.36
5.3.210.0120.05526.36
5.3.200.0150.04626.37
5.3.190.0070.06426.36
5.3.180.0110.05826.36
5.3.170.0120.05626.36
5.3.160.0090.05026.36
5.3.150.0110.04726.36
5.3.140.0080.05526.35
5.3.130.0150.05826.34
5.3.120.0090.05326.35
5.3.110.0130.04826.35
5.3.100.0100.04725.83
5.3.90.0170.05225.82
5.3.80.0120.04625.80
5.3.70.0120.04725.80
5.3.60.0090.05325.78
5.3.50.0090.05425.73
5.3.40.0130.06225.73
5.3.30.0120.04825.70
5.3.20.0120.04625.47
5.3.10.0130.04425.43
5.3.00.0110.05025.42
5.2.170.0050.05222.15
5.2.160.0110.03922.35
5.2.150.0090.04322.15
5.2.140.0040.04522.14
5.2.130.0120.03622.11
5.2.120.0090.03922.31
5.2.110.0070.04122.10
5.2.100.0100.03922.11
5.2.90.0100.03922.11
5.2.80.0050.04722.10
5.2.70.0100.04322.30
5.2.60.0120.05622.05
5.2.50.0100.05522.15
5.2.40.0090.04722.12
5.2.30.0130.04822.10
5.2.20.0140.04922.11
5.2.10.0120.03922.02
5.2.00.0120.04321.88
5.1.60.0180.05025.68
5.1.50.0180.04925.69
5.1.40.0120.05525.67
5.1.30.0160.05326.01
5.1.20.0090.04126.04
5.1.10.0110.03725.77
5.1.00.0090.04825.76
5.0.50.0060.0226.61
5.0.40.0050.0186.46
5.0.30.0020.0416.29
5.0.20.0030.0206.25
5.0.10.0030.0206.23
5.0.00.0040.0306.23
4.4.90.0050.0164.78
4.4.80.0030.0164.75
4.4.70.0020.0164.75
4.4.60.0040.0144.75
4.4.50.0030.0154.77
4.4.40.0010.0294.71
4.4.30.0070.0174.76
4.4.20.0040.0154.84
4.4.10.0040.0184.85
4.4.00.0020.0264.76
4.3.110.0020.0174.66
4.3.100.0030.0154.66
4.3.90.0020.0204.63
4.3.80.0020.0254.58
4.3.70.0020.0154.63
4.3.60.0030.0154.63
4.3.50.0010.0174.63
4.3.40.0050.0224.54
4.3.30.0020.0163.29
4.3.20.0020.0163.27
4.3.10.0020.0163.24
4.3.00.0100.0136.95

preferences:
44.7 ms | 401 KiB | 5 Q