3v4l.org

run code in 300+ PHP versions simultaneously
<?php function binary_search(array $array, int $target) { $max = count($array) - 2; $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.60.0090.00618.49
8.3.50.0110.01418.28
8.3.40.0070.00718.83
8.3.30.0070.00718.56
8.3.20.0060.00319.46
8.3.10.0040.00421.73
8.3.00.0080.00020.52
8.2.180.0130.00616.63
8.2.170.0120.00922.96
8.2.160.0100.00322.12
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.01221.01
8.2.110.0080.00321.18
8.2.100.0070.00417.84
8.2.90.0070.00319.26
8.2.80.0000.00817.97
8.2.70.0030.00518.05
8.2.60.0050.00318.34
8.2.50.0000.00918.10
8.2.40.0000.00719.48
8.2.30.0050.00219.26
8.2.20.0050.00218.25
8.2.10.0030.00518.05
8.2.00.0060.00317.71
8.1.280.0110.00425.92
8.1.270.0050.00318.98
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00022.51
8.1.230.0040.00720.96
8.1.220.0040.00417.80
8.1.210.0080.00018.93
8.1.200.0000.00817.35
8.1.190.0030.00617.35
8.1.180.0000.00818.10
8.1.170.0000.00818.54
8.1.160.0040.00418.86
8.1.150.0070.00018.88
8.1.140.0030.00322.06
8.1.130.0000.00720.27
8.1.120.0000.00717.31
8.1.110.0000.00817.45
8.1.100.0040.00417.44
8.1.90.0070.00017.45
8.1.80.0000.00717.53
8.1.70.0040.00417.50
8.1.60.0030.00517.64
8.1.50.0000.00817.52
8.1.40.0000.00817.55
8.1.30.0070.00317.64
8.1.20.0000.00717.56
8.1.10.0040.00417.51
8.1.00.0050.00217.49
8.0.300.0030.00619.91
8.0.290.0000.00716.75
8.0.280.0000.00718.43
8.0.270.0070.00017.30
8.0.260.0030.00318.51
8.0.250.0030.00316.98
8.0.240.0050.00316.97
8.0.230.0040.00416.97
8.0.220.0030.00316.88
8.0.210.0000.00716.76
8.0.200.0030.00316.97
8.0.190.0050.00516.89
8.0.180.0000.00716.81
8.0.170.0060.00316.84
8.0.160.0040.00416.93
8.0.150.0070.00016.84
8.0.140.0030.00316.89
8.0.130.0030.00313.30
8.0.120.0050.00316.77
8.0.110.0040.00416.75
8.0.100.0040.00416.80
8.0.90.0040.00416.81
8.0.80.0070.00916.90
8.0.70.0070.00016.79
8.0.60.0030.00516.77
8.0.50.0000.00716.70
8.0.30.0140.00616.94
8.0.20.0150.00317.40
8.0.10.0040.00417.13
8.0.00.0120.00716.79
7.4.330.0000.00515.55
7.4.320.0000.00716.52
7.4.300.0030.00316.61
7.4.290.0030.00316.61
7.4.280.0000.00816.45
7.4.270.0020.00516.67
7.4.260.0000.00816.67
7.4.250.0020.00416.47
7.4.240.0030.00316.63
7.4.230.0070.00016.36
7.4.220.0060.00316.68
7.4.210.0080.00916.69
7.4.200.0000.00716.68
7.4.160.0120.00516.58
7.4.140.0110.00717.86
7.4.130.0120.00616.64
7.4.120.0100.00816.54
7.4.110.0090.00916.45
7.4.100.0070.01016.46
7.4.90.0080.00916.58
7.4.80.0080.00819.39
7.4.70.0040.01716.44
7.4.60.0070.01016.50
7.4.50.0070.00316.20
7.4.40.0080.00916.22
7.4.00.0110.00615.02
7.3.330.0000.00613.19
7.3.320.0000.00613.20
7.3.310.0060.00316.38
7.3.300.0070.00016.24
7.3.290.0000.00716.29
7.3.280.0070.01216.35
7.3.260.0080.01016.46
7.3.240.0090.00916.51
7.3.230.0030.01316.67
7.3.210.0110.00716.61
7.3.200.0030.01316.54
7.3.190.0090.01316.61
7.3.180.0070.01716.48
7.3.170.0070.01616.54
7.3.160.0030.01316.51
7.3.120.0040.01514.98
7.3.110.0140.00714.78
7.3.100.0040.01815.14
7.3.90.0040.01114.98
7.3.80.0120.00015.05
7.3.70.0090.00614.94
7.3.60.0000.00914.91
7.3.50.0040.00414.88
7.3.40.0000.00914.96
7.3.30.0060.00914.85
7.3.20.0090.00616.75
7.3.10.0060.00316.75
7.3.00.0040.01116.68
7.2.330.0100.00716.48
7.2.320.0110.00716.73
7.2.310.0090.00916.64
7.2.300.0140.00216.57
7.2.290.0030.01416.54
7.2.250.0040.01515.09
7.2.240.0090.00614.77
7.2.230.0060.01015.13
7.2.220.0030.01015.32
7.2.210.0060.00315.05
7.2.200.0060.00615.03
7.2.190.0030.00615.00
7.2.180.0100.00615.10
7.2.170.0080.00615.21
7.2.160.0030.00615.28
7.2.150.0100.00317.03
7.2.140.0110.00416.70
7.2.130.0000.01017.03
7.2.120.0060.00617.02
7.2.110.0470.01215.86
7.2.100.0290.01315.86
7.2.90.0530.00615.84
7.2.80.0320.01115.90
7.2.70.0300.01115.86
7.2.60.0310.00315.79
7.2.50.0370.00915.91
7.2.40.0300.00916.00
7.2.30.0380.00716.00
7.2.20.0250.00615.91
7.2.10.0320.00315.94
7.2.00.0320.01115.81
7.1.330.0060.01315.86
7.1.320.0060.00915.59
7.1.310.0110.00015.78
7.1.300.0050.00515.86
7.1.290.0060.01315.77
7.1.280.0080.00015.64
7.1.270.0030.01215.99
7.1.260.0000.01515.90
7.1.250.0090.00315.89
7.1.240.0030.01015.91
7.1.230.0550.00514.86
7.1.220.0340.00714.88
7.1.210.0350.00414.81
7.1.200.0440.01214.71
7.1.190.0390.00514.96
7.1.180.0300.00614.85
7.1.170.0340.01414.97
7.1.160.0450.00614.85
7.1.150.0360.00814.92
7.1.140.0340.00614.68
7.1.130.0230.01014.71
7.1.120.0220.01014.69
7.1.110.0310.00814.77
7.1.100.0360.00514.78
7.1.90.0190.00514.81
7.1.80.0270.00514.63
7.1.70.0400.00914.71
7.1.60.0470.00923.74
7.1.50.0170.01223.82
7.1.40.0190.01223.74
7.1.30.0130.01123.87
7.1.20.0200.00323.81
7.1.10.0750.00814.82
7.1.00.0510.00514.97
7.0.330.0100.00315.45
7.0.320.0060.00915.55
7.0.310.0110.00415.44
7.0.300.0070.00315.40
7.0.290.0080.01115.54
7.0.280.0070.01115.18
7.0.270.0110.00315.11
7.0.260.0030.01415.47
7.0.250.0100.00715.42
7.0.240.0090.00615.49
7.0.230.0130.00015.39
7.0.220.0060.00915.37
7.0.210.0000.01115.20
7.0.200.0090.00015.28
7.0.190.0080.00815.25
7.0.180.0080.00815.61
7.0.170.0030.01315.43
7.0.160.0120.00015.50
7.0.150.0030.00815.49
7.0.140.0000.01315.57
7.0.130.0060.00315.38
7.0.120.0060.00615.46
7.0.110.0090.00615.50
7.0.100.0040.00415.39
7.0.90.0070.01115.38
7.0.80.0080.00615.53
7.0.70.0090.00615.63
7.0.60.0040.00415.42
7.0.50.0000.01115.52
7.0.40.0030.01013.60
7.0.30.0060.00613.42
7.0.20.0110.00013.26
7.0.10.0040.00413.39
7.0.00.0000.01113.47
5.6.400.0030.01414.47
5.6.390.0130.00314.55
5.6.380.0110.00714.54
5.6.370.0100.00714.08
5.6.360.0060.01214.34
5.6.350.0090.00314.23
5.6.340.0030.01413.92
5.6.330.0070.01014.38
5.6.320.0040.01214.64
5.6.310.0040.01114.52
5.6.300.0060.01014.21
5.6.290.0110.00314.24
5.6.280.0070.00714.26
5.6.270.0060.00614.28
5.6.260.0000.01214.23
5.6.250.0040.01414.34
5.6.240.0090.00614.15
5.6.230.0090.00914.00
5.6.220.0150.00014.36
5.6.210.0060.00614.16
5.6.200.0000.01514.34
5.6.190.0000.01414.19
5.6.180.0070.00714.38
5.6.170.0050.00814.38
5.6.160.0030.01014.35
5.6.150.0100.00614.29
5.6.140.0060.00314.38
5.6.130.0080.00314.18
5.6.120.0000.00914.27
5.6.110.0040.00814.23
5.6.100.0040.00814.22
5.6.90.0030.00914.02
5.6.80.0080.00814.04
5.6.70.0030.01014.45
5.6.60.0100.00014.08
5.6.50.0000.00914.45
5.6.40.0090.00614.13
5.6.30.0000.01513.93
5.6.20.0040.00814.13
5.6.10.0070.00714.27
5.6.00.0090.00014.07

preferences:
54.55 ms | 401 KiB | 5 Q