3v4l.org

run code in 300+ PHP versions simultaneously
<?php function binary_search(array $array, int $target) { $max = count($array) - 1; $min = 0; while ($max - $min > 1) { if ($target < $array[($max - $min) / 2]) { $max = ($max + $min) / 2; } else { $min = ($max + $min) / 2; } } return $result = $array[$max + $min / 2] === $target ? true : false; } echo('Searching for 6 in 1,2,3,4,5,6'); $array = [1,2,3,4,5,6]; $target = 6; $result = binary_search($array, $target); echo($result); echo('Searching for 3 in 1,2,3,4,5'); $array = [1,2,3,4,5]; $target = 3; $result = binary_search($array, $target); echo($result);

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.40.0040.01118.65
8.3.30.0000.01418.78
8.3.20.0000.00819.28
8.3.10.0080.00021.94
8.3.00.0000.00820.52
8.2.170.0090.00622.96
8.2.160.0070.00722.17
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0000.00718.09
8.2.120.0080.00026.35
8.2.110.0060.00320.94
8.2.100.0070.00418.03
8.2.90.0060.00619.38
8.2.80.0050.00517.97
8.2.70.0080.00018.05
8.2.60.0060.00317.91
8.2.50.0050.00318.10
8.2.40.0000.00719.46
8.2.30.0030.00619.32
8.2.20.0000.00818.16
8.2.10.0060.00318.14
8.2.00.0000.00817.84
8.1.270.0000.00818.91
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0090.00022.61
8.1.230.0080.00320.95
8.1.220.0000.00817.78
8.1.210.0040.00418.85
8.1.200.0090.00017.35
8.1.190.0000.01017.11
8.1.180.0030.00518.10
8.1.170.0000.00818.54
8.1.160.0040.00418.77
8.1.150.0040.00418.80
8.1.140.0070.00022.07
8.1.130.0050.00220.21
8.1.120.0040.00417.48
8.1.110.0000.00717.45
8.1.100.0070.00017.41
8.1.90.0000.00717.38
8.1.80.0000.00717.44
8.1.70.0050.00217.45
8.1.60.0060.00317.57
8.1.50.0080.00017.53
8.1.40.0000.00817.47
8.1.30.0080.00317.68
8.1.20.0000.00817.65
8.1.10.0040.00417.53
8.1.00.0040.00417.37
8.0.300.0000.00819.98
8.0.290.0040.00416.88
8.0.280.0000.00718.50
8.0.270.0070.00017.27
8.0.260.0000.00618.41
8.0.250.0030.00317.05
8.0.240.0070.00016.92
8.0.230.0000.00817.00
8.0.220.0050.00316.96
8.0.210.0030.00316.85
8.0.200.0000.00616.93
8.0.190.0030.00616.96
8.0.180.0000.00816.90
8.0.170.0060.00317.00
8.0.160.0070.00016.95
8.0.150.0000.00716.95
8.0.140.0000.00716.80
8.0.130.0000.00513.34
8.0.120.0040.00416.95
8.0.110.0050.00316.95
8.0.100.0000.00716.98
8.0.90.0040.00417.03
8.0.80.0130.00617.03
8.0.70.0030.00517.02
8.0.60.0030.00516.84
8.0.50.0000.00716.94
8.0.30.0080.01117.09
8.0.20.0090.00917.40
8.0.10.0020.00517.05
8.0.00.0120.00616.70
7.4.330.0050.00015.55
7.4.320.0080.00016.37
7.4.300.0040.00416.59
7.4.290.0030.00316.49
7.4.280.0050.00316.63
7.4.270.0050.00316.52
7.4.260.0030.00316.64
7.4.250.0000.00716.54
7.4.240.0000.00816.46
7.4.230.0030.00316.48
7.4.220.0000.00716.36
7.4.210.0080.00616.61
7.4.200.0000.00716.69
7.4.160.0050.01216.57
7.4.140.0100.00917.86
7.4.130.0090.01216.38
7.4.120.0100.01016.65
7.4.110.0110.01416.38
7.4.100.0100.01016.45
7.4.90.0140.00316.40
7.4.80.0160.00619.39
7.4.70.0120.00616.43
7.4.60.0120.00416.37
7.4.50.0070.00716.47
7.4.40.0070.01416.72
7.4.10.0060.01215.28
7.4.00.0040.01414.83
7.3.330.0050.00013.41
7.3.320.0000.00513.29
7.3.310.0000.00816.45
7.3.300.0000.00716.48
7.3.290.0070.00016.39
7.3.280.0130.00316.44
7.3.260.0090.01116.49
7.3.240.0100.00816.49
7.3.230.0190.00016.65
7.3.210.0130.00716.55
7.3.200.0130.00316.38
7.3.190.0150.00316.58
7.3.180.0060.00916.67
7.3.170.0180.00016.49
7.3.160.0180.00316.38
7.3.130.0050.01314.95
7.3.120.0130.00614.79
7.3.110.0070.01214.83
7.3.100.0060.00914.89
7.3.90.0060.01014.95
7.3.80.0020.01214.93
7.3.70.0050.00714.93
7.3.60.0100.00514.82
7.3.50.0040.00414.89
7.3.40.0030.01014.74
7.3.30.0090.00514.71
7.3.20.0070.00716.77
7.3.10.0070.00816.64
7.3.00.0030.01116.60
7.2.330.0000.01816.77
7.2.320.0130.01416.84
7.2.310.0070.01316.75
7.2.300.0100.00716.59
7.2.290.0000.01716.84
7.2.260.0070.01414.95
7.2.250.0100.00615.02
7.2.240.0080.01015.17
7.2.230.0100.00814.98
7.2.220.0070.00915.37
7.2.210.0050.00915.08
7.2.200.0080.00914.83
7.2.190.0060.00615.11
7.2.180.0060.00915.12
7.2.170.0050.01015.21
7.2.160.0030.00615.15
7.2.150.0070.01016.83
7.2.140.0070.00716.79
7.2.130.0040.01116.84
7.2.120.0030.01116.96
7.2.110.0320.00816.15
7.2.100.0350.00916.04
7.2.90.0540.00916.03
7.2.80.0320.00516.20
7.2.70.0340.00616.28
7.2.60.0450.00916.17
7.2.50.0440.00916.33
7.2.40.0310.00916.36
7.2.30.0460.00516.20
7.2.20.0310.01016.24
7.2.10.0480.01016.31
7.2.00.0190.01116.21
7.1.330.0090.00615.77
7.1.320.0080.00815.87
7.1.310.0060.00815.65
7.1.300.0030.00915.88
7.1.290.0040.00715.85
7.1.280.0080.00615.96
7.1.270.0030.00915.74
7.1.260.0060.00515.88
7.1.250.0060.00315.79
7.1.240.0030.00915.91
7.1.230.0330.00614.79
7.1.220.0220.00814.86
7.1.210.0400.00914.69
7.1.200.0560.00614.75
7.1.190.0530.01014.79
7.1.180.0620.00614.85
7.1.170.0530.01214.93
7.1.160.0430.00615.00
7.1.150.0380.01114.90
7.1.140.0740.00714.96
7.1.130.0230.00414.70
7.1.120.0390.00714.83
7.1.110.0380.00714.79
7.1.100.0360.00614.74
7.1.90.0640.00214.78
7.1.80.0570.00714.62
7.1.70.0620.00614.60
7.1.60.0280.01323.74
7.1.50.0580.01023.59
7.1.40.0600.01123.81
7.1.30.0590.01123.59
7.1.20.0410.01023.87
7.1.10.0520.01014.86
7.1.00.0350.00914.95
7.0.330.0060.00615.41
7.0.320.0060.00815.46
7.0.310.0050.00515.44
7.0.300.0000.00815.35
7.0.290.0070.00715.59
7.0.280.0090.00015.20
7.0.270.0040.00715.24
7.0.260.0100.00315.51
7.0.250.0050.00315.23
7.0.240.0000.01115.36
7.0.230.0070.00715.45
7.0.220.0070.00315.53
7.0.210.0030.00615.53
7.0.200.0060.00515.20
7.0.190.0040.00415.56
7.0.180.0060.00615.27
7.0.170.0030.00615.55
7.0.160.0050.00515.43
7.0.150.0070.00715.46
7.0.140.0040.00415.18
7.0.130.0090.00615.45
7.0.120.0000.01415.50
7.0.110.0030.01015.30
7.0.100.0030.01015.38
7.0.90.0080.00415.44
7.0.80.0030.01415.41
7.0.70.0090.00315.48
7.0.60.0090.00315.46
7.0.50.0130.00015.42
7.0.40.0030.00613.69
7.0.30.0090.00013.54
7.0.20.0100.00313.62
7.0.10.0060.00613.36
7.0.00.0070.00713.25
5.6.400.0070.00714.05
5.6.390.0080.00314.49
5.6.380.0070.00613.92
5.6.370.0030.00614.38
5.6.360.0030.00514.39
5.6.350.0040.00414.46
5.6.340.0030.00914.45
5.6.330.0030.00714.15
5.6.320.0100.00014.55
5.6.310.0030.00714.50
5.6.300.0000.01413.93
5.6.290.0000.00914.19
5.6.280.0040.01114.04
5.6.270.0100.00314.33
5.6.260.0000.00914.37
5.6.250.0030.01014.43
5.6.240.0070.00714.10
5.6.230.0000.00914.23
5.6.220.0100.00014.34
5.6.210.0070.00714.41
5.6.200.0040.01114.44
5.6.190.0090.00613.99
5.6.180.0060.00614.34
5.6.170.0080.00514.08
5.6.160.0000.00814.45
5.6.150.0030.00914.05
5.6.140.0030.00914.12
5.6.130.0040.00914.28
5.6.120.0070.01014.33
5.6.110.0030.00714.17
5.6.100.0090.00614.34
5.6.90.0080.00614.26
5.6.80.0030.01214.48
5.6.70.0040.00414.24
5.6.60.0040.00414.15
5.6.50.0060.00313.98
5.6.40.0040.00414.21
5.6.30.0090.00014.12
5.6.20.0070.00714.11
5.6.10.0040.01214.31
5.6.00.0080.00414.19

preferences:
81.67 ms | 400 KiB | 5 Q