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.70.0420.01317.99
8.3.60.0200.01320.17
8.3.50.0110.00722.92
8.3.40.0110.00720.34
8.3.30.0230.00720.70
8.3.20.0060.01121.98
8.3.10.0120.00324.08
8.3.00.0110.00324.40
8.2.180.0390.01318.00
8.2.170.0260.00922.96
8.2.160.0170.00022.99
8.2.150.0080.00824.18
8.2.140.0100.00024.66
8.2.130.0120.00026.16
8.2.120.0170.00421.58
8.2.110.0150.00424.47
8.2.100.0170.00019.53
8.2.90.0030.00720.59
8.2.80.0040.01319.55
8.2.70.0070.00719.25
8.2.60.0060.00319.30
8.2.50.0100.00019.25
8.2.40.0080.00819.72
8.2.30.0030.00619.80
8.2.20.0030.00619.45
8.2.10.0060.00319.40
8.2.00.0190.00019.29
8.1.280.0160.00325.92
8.1.270.0050.00527.10
8.1.260.0040.00826.35
8.1.250.0180.00428.09
8.1.240.0080.00428.01
8.1.230.0120.00922.04
8.1.220.0080.00820.68
8.1.210.0080.00320.48
8.1.200.0070.00720.38
8.1.190.0090.00020.66
8.1.180.0070.00320.36
8.1.170.0070.00721.77
8.1.160.0040.00425.20
8.1.150.0070.00321.79
8.1.140.0040.00820.70
8.1.130.0060.00320.93
8.1.120.0060.00320.63
8.1.110.0030.00620.63
8.1.100.0080.00820.68
8.1.90.0120.00820.63
8.1.80.0030.00720.61
8.1.70.0040.00720.65
8.1.60.0030.00720.79
8.1.50.0030.00620.75
8.1.40.0060.00620.67
8.1.30.0040.00820.79
8.1.20.0030.00720.79
8.1.10.0000.00920.71
8.1.00.0000.01420.54
8.0.300.0090.00320.35
8.0.290.0040.00820.04
8.0.280.0090.00021.39
8.0.270.0030.00720.28
8.0.260.0110.00519.88
8.0.250.0090.00319.93
8.0.240.0040.00820.01
8.0.230.0000.01319.84
8.0.220.0080.00819.85
8.0.210.0120.00019.83
8.0.200.0090.00920.08
8.0.190.0000.01219.89
8.0.180.0090.00619.85
8.0.170.0120.00619.96
8.0.160.0120.00619.96
8.0.150.0040.01219.90
8.0.140.0000.01319.82
8.0.130.0000.00916.53
8.0.120.0120.00019.94
8.0.110.0060.00319.95
8.0.100.0040.01319.85
8.0.90.0090.00919.78
8.0.80.0200.03719.88
8.0.70.0100.00619.90
8.0.60.0000.01919.78
8.0.50.0030.00719.78
8.0.30.0330.02020.10
8.0.20.0270.01020.21
8.0.10.0030.00620.00
8.0.00.0170.01919.85
7.4.330.0000.00719.07
7.4.320.0030.00619.49
7.4.300.0040.00719.48
7.4.290.0100.00619.48
7.4.280.0030.00719.57
7.4.270.0000.00919.61
7.4.260.0040.00819.53
7.4.250.0060.00619.60
7.4.240.0030.00919.61
7.4.230.0080.00319.62
7.4.220.0200.03119.68
7.4.210.0200.01619.54
7.4.200.0040.00719.43
7.4.190.0050.01019.41
7.4.160.0460.01519.39
7.4.150.0250.02619.44
7.4.140.0270.01919.44
7.4.130.0410.01719.46
7.4.120.0470.01719.66
7.4.110.1230.04319.66
7.4.100.0550.01719.69
7.4.90.0740.02819.59
7.4.80.0210.01319.61
7.4.70.0300.01619.57
7.4.60.0170.02119.48
7.4.50.0090.00319.57
7.4.40.0130.00622.77
7.4.30.0470.05219.57
7.4.00.0090.01118.10
7.3.330.0050.00516.48
7.3.320.0030.00616.43
7.3.310.0070.00419.35
7.3.300.0050.00519.29
7.3.290.0210.01719.39
7.3.280.0150.01819.36
7.3.270.0370.01719.48
7.3.260.0170.02219.36
7.3.250.0440.02719.46
7.3.240.0280.02119.43
7.3.230.0990.03319.32
7.3.210.0490.01819.53
7.3.200.0190.01619.39
7.3.190.0300.01919.60
7.3.180.0380.03419.53
7.3.170.0310.01619.21
7.3.160.0590.03519.60
7.3.120.0060.01217.96
7.2.330.0160.02819.95
7.2.320.0390.02819.88
7.2.310.0230.02919.91
7.2.300.0370.02619.88
7.2.290.0600.01419.64
7.2.60.0070.01020.87
7.1.200.0180.00319.75
7.1.100.1020.00920.09
7.1.70.0160.01020.74
7.1.60.0030.02621.47
7.1.50.0230.00921.14
7.0.200.0200.00020.88

preferences:
47.16 ms | 401 KiB | 5 Q