3v4l.org

run code in 300+ PHP versions simultaneously
<?php // arrB to not get changes reflected once we sort $arrB = $array = [4, 1, 5, 52, 75, 52, 24]; function findMinDiff($arr) { $n = count($arr); // Initialize difference // as infinite $diff = PHP_INT_MAX; // Find the min diff by comparing // difference of all possible // pairs in given array $two_values = []; for ($i = 0; $i < $n - 1; $i++) { for ($j = $i + 1; $j < $n; $j++) { if (abs($arr[$i] - $arr[$j]) < $diff) { $diff = abs($arr[$i] - $arr[$j]); $two_values['values'] = [$arr[$i], $arr[$j]]; $two_values['keys'] = [$i, $j]; $two_values['diff'] = $diff; } } } // Return min diff return $two_values; } print_r(findMinDiff($array));

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.4.20.0130.00620.70
8.4.10.0060.01019.57
8.3.150.0000.01417.54
8.3.140.0070.01120.70
8.3.130.0130.00718.20
8.3.120.0040.00419.11
8.3.110.0050.00320.94
8.3.100.0040.00416.66
8.3.90.0030.00518.41
8.3.80.0060.00318.55
8.3.70.0180.00016.50
8.3.60.0040.01118.30
8.3.50.0100.01116.44
8.3.40.0060.00918.71
8.3.30.0090.00618.67
8.3.20.0070.00021.95
8.3.10.0030.00521.78
8.3.00.0030.00523.61
8.2.260.0110.00717.12
8.2.250.0040.00416.96
8.2.240.0050.00517.38
8.2.230.0080.00822.58
8.2.220.0060.00324.06
8.2.210.0140.00426.77
8.2.200.0100.00018.15
8.2.190.0060.01216.63
8.2.180.0120.00316.50
8.2.170.0140.00718.72
8.2.160.0120.00322.96
8.2.150.0040.00424.18
8.2.140.0110.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00019.48
8.2.110.0040.00419.21
8.2.100.0080.00418.09
8.2.90.0040.00418.16
8.2.80.0060.00318.05
8.2.70.0060.00318.16
8.2.60.0080.00017.63
8.2.50.0000.00917.63
8.2.40.0040.00417.75
8.2.30.0040.00419.34
8.2.20.0000.00818.21
8.2.10.0080.00018.98
8.2.00.0040.00419.22
8.1.310.0080.00016.86
8.1.300.0000.00816.03
8.1.290.0030.00618.88
8.1.280.0110.00425.92
8.1.270.0050.00523.82
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00022.58
8.1.230.0040.00720.88
8.1.220.0060.00317.77
8.1.210.0000.00818.77
8.1.200.0070.00317.35
8.1.190.0080.00017.22
8.1.180.0040.00418.10
8.1.170.0030.00618.52
8.1.160.0040.00418.91
8.1.150.0040.00418.94
8.1.140.0040.00418.93
8.1.130.0000.00720.05
8.1.120.0040.00417.50
8.1.110.0000.00717.48
8.1.100.0030.00517.44
8.1.90.0050.00217.48
8.1.80.0000.00717.40
8.1.70.0000.00717.50
8.1.60.0080.00017.63
8.1.50.0030.00617.61
8.1.40.0040.00417.59
8.1.30.0030.00517.59
8.1.20.0040.00417.71
8.1.10.0050.00817.53
8.1.00.0030.00717.52
8.0.300.0040.00419.83
8.0.290.0000.00716.75
8.0.280.0000.00718.42
8.0.270.0030.00317.28
8.0.260.0080.00018.39
8.0.250.0000.00716.99
8.0.240.0000.00716.98
8.0.230.0030.00316.90
8.0.220.0000.00716.96
8.0.210.0030.00316.85
8.0.200.0030.00316.98
8.0.190.0080.00016.99
8.0.180.0040.00416.99
8.0.170.0000.00816.94
8.0.160.0040.00416.78
8.0.150.0050.00216.92
8.0.140.0020.00516.77
8.0.130.0000.00613.29
8.0.120.0040.00416.86
8.0.110.0090.00016.88
8.0.100.0040.00416.88
8.0.90.0000.00816.80
8.0.80.0090.00616.95
8.0.70.0000.00716.86
8.0.60.0070.00016.82
8.0.50.0040.00416.73
8.0.30.0070.01017.09
8.0.20.0100.01016.98
8.0.10.0040.00417.01
8.0.00.0110.01016.74
7.4.330.0030.00315.55
7.4.320.0030.00316.45
7.4.300.0030.00316.53
7.4.290.0070.00016.46
7.4.280.0040.00416.45
7.4.270.0090.00016.63
7.4.260.0040.00416.48
7.4.250.0060.00316.61
7.4.240.0020.00516.58
7.4.230.0040.00416.62
7.4.220.0050.00316.64
7.4.210.0040.01016.56
7.4.200.0080.00016.54
7.4.160.0100.00916.60
7.4.140.0110.00717.86
7.4.130.0000.01816.53
7.4.120.0070.01416.48
7.4.110.0060.01616.44
7.4.100.0030.01616.48
7.4.90.0130.00316.55
7.4.80.0100.00719.39
7.4.70.0120.00616.60
7.4.60.0060.01016.70
7.4.50.0060.00616.74
7.4.40.0090.00916.64
7.4.00.0100.00315.05
7.3.330.0030.00313.26
7.3.320.0050.00013.47
7.3.310.0000.00716.41
7.3.300.0030.00316.28
7.3.290.0000.00616.44
7.3.280.0110.00816.34
7.3.260.0090.00916.59
7.3.240.0130.00816.52
7.3.230.0080.01216.37
7.3.210.0090.01516.38
7.3.200.0090.00916.46
7.3.190.0120.00416.54
7.3.180.0060.00916.45
7.3.170.0100.01316.34
7.3.160.0080.00816.57
7.3.60.0100.00514.92
7.3.50.0070.00414.95
7.3.40.0090.00314.95
7.3.30.0070.00714.91
7.3.20.0040.00716.75
7.3.10.0110.00416.65
7.3.00.0090.00316.78
7.2.330.0080.01116.62
7.2.320.0100.01016.43
7.2.310.0060.01016.78
7.2.300.0040.01516.64
7.2.290.0090.00616.83
7.2.190.0030.00915.09
7.2.180.0090.00315.07
7.2.170.0090.00315.07
7.2.160.0100.00314.94
7.2.150.0100.01116.86
7.2.140.0090.00616.84
7.2.130.0120.00016.83
7.2.120.0100.00316.85
7.2.110.0120.00916.98
7.2.100.0060.00916.97
7.2.90.0070.00816.89
7.2.80.0060.00916.87
7.2.70.0060.00917.01
7.2.60.0080.00816.96
7.2.50.0090.00616.92
7.2.40.0120.00417.00
7.2.30.0000.01116.90
7.2.20.0100.00316.66
7.2.10.0060.01616.69
7.2.00.0030.01617.08
7.1.300.0130.00315.70
7.1.290.0030.01015.89
7.1.280.0000.01315.80
7.1.270.0050.00515.83
7.1.260.0030.01015.69
7.1.250.0040.00715.84

preferences:
38.44 ms | 406 KiB | 6 Q