3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ /*:: :*/ /*:: This routine calculates the distance between two points (given the :*/ /*:: latitude/longitude of those points). It is being used to calculate :*/ /*:: the distance between two locations using GeoDataSource(TM) Products :*/ /*:: :*/ /*:: Definitions: :*/ /*:: South latitudes are negative, east longitudes are positive :*/ /*:: :*/ /*:: Passed to function: :*/ /*:: lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees) :*/ /*:: lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees) :*/ /*:: unit = the unit you desire for results :*/ /*:: where: 'M' is statute miles :*/ /*:: 'K' is kilometers (default) :*/ /*:: 'N' is nautical miles :*/ /*:: Worldwide cities and other features databases with latitude longitude :*/ /*:: are available at http://www.geodatasource.com :*/ /*:: :*/ /*:: For enquiries, please contact sales@geodatasource.com :*/ /*:: :*/ /*:: Official Web site: http://www.geodatasource.com :*/ /*:: :*/ /*:: GeoDataSource.com (C) All Rights Reserved 2014 :*/ /*:: :*/ /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ function distance($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } else if ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } } echo distance(32.9697, -96.80322, 29.46786, -98.53506, "M") . " Miles<br>"; echo distance(32.9697, -96.80322, 29.46786, -98.53506, "K") . " Kilometers<br>"; echo distance(32.9697, -96.80322, 29.46786, -98.53506, "N") . " Nautical Miles<br>"; ?>

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.01119.06
8.3.30.0070.01019.31
8.3.20.0040.00420.54
8.3.10.0040.00424.03
8.3.00.0030.00717.75
8.2.170.0120.00319.42
8.2.160.0040.01122.96
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0050.00322.79
8.2.110.0070.00319.51
8.2.100.0060.00618.53
8.2.90.0000.00719.47
8.2.80.0080.00017.97
8.2.70.0000.00817.98
8.2.60.0000.01018.05
8.2.50.0080.00018.07
8.2.40.0050.00320.26
8.2.30.0070.00018.36
8.2.20.0040.00418.05
8.2.10.0060.00318.49
8.2.00.0040.00818.20
8.1.270.0000.00824.19
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00324.20
8.1.230.0000.01119.59
8.1.220.0040.00418.02
8.1.210.0050.00318.77
8.1.200.0030.00617.60
8.1.190.0050.00317.73
8.1.180.0030.00518.10
8.1.170.0040.00419.16
8.1.160.0000.00722.36
8.1.150.0040.00419.21
8.1.140.0000.00717.81
8.1.130.0030.00318.21
8.1.120.0040.00417.84
8.1.110.0080.00017.69
8.1.100.0040.00417.73
8.1.90.0050.00217.86
8.1.80.0040.00417.79
8.1.70.0030.00517.80
8.1.60.0030.00618.00
8.1.50.0060.00317.97
8.1.40.0000.00817.91
8.1.30.0040.00418.04
8.1.20.0000.00717.85
8.1.10.0070.00017.92
8.1.00.0000.00917.83
8.0.300.0040.00418.77
8.0.290.0050.00317.25
8.0.280.0000.00719.02
8.0.270.0070.00017.79
8.0.260.0000.00717.62
8.0.250.0070.00017.33
8.0.240.0000.00717.21
8.0.230.0080.00017.31
8.0.220.0000.00717.31
8.0.210.0070.00017.23
8.0.200.0030.00317.20
8.0.190.0030.00617.42
8.0.180.0030.00517.20
8.0.170.0060.00317.23
8.0.160.0070.00017.15
8.0.150.0000.00717.21
8.0.140.0030.00417.25
8.0.130.0030.00313.68
8.0.120.0030.00517.23
8.0.110.0000.00717.29
8.0.100.0000.00717.19
8.0.90.0000.00817.41
8.0.80.0100.00617.07
8.0.70.0040.00417.24
8.0.60.0040.00417.48
8.0.50.0040.00417.25
8.0.30.0100.01217.25
8.0.20.0110.00817.49
8.0.10.0070.00017.20
8.0.00.0080.00816.91
7.4.330.0050.00015.00
7.4.320.0000.00616.93
7.4.300.0060.00016.96
7.4.290.0000.00716.90
7.4.280.0040.00416.91
7.4.270.0030.00316.89
7.4.260.0070.00016.81
7.4.250.0040.00416.95
7.4.240.0010.00616.93
7.4.230.0070.00016.96
7.4.220.0030.01616.82
7.4.210.0060.01016.65
7.4.200.0050.00516.79
7.4.160.0040.01216.73
7.4.150.0100.01017.40
7.4.140.0100.00817.86
7.4.130.0100.00716.78
7.4.120.0050.01116.70
7.4.110.0140.00316.61
7.4.100.0100.01316.77
7.4.90.0060.00916.88
7.4.80.0150.00419.39
7.4.70.0090.00916.53
7.4.60.0090.00916.86
7.4.50.0080.00016.84
7.4.40.0100.01016.47
7.4.30.0170.00316.72
7.4.00.0000.01515.01
7.3.330.0030.00213.68
7.3.320.0000.00513.66
7.3.310.0030.00316.55
7.3.300.0060.00016.68
7.3.290.0100.00316.46
7.3.280.0080.01016.47
7.3.270.0110.00717.40
7.3.260.0080.00816.78
7.3.250.0070.00916.59
7.3.240.0060.01016.64
7.3.230.0100.00516.46
7.3.210.0070.01016.50
7.3.200.0100.00719.39
7.3.190.0090.00916.75
7.3.180.0060.01216.41
7.3.170.0100.00616.56
7.3.160.0090.00916.54
7.3.10.0080.01316.71
7.3.00.0140.00716.62
7.2.330.0120.00816.67
7.2.320.0120.00616.73
7.2.310.0110.00616.99
7.2.300.0060.00916.89
7.2.290.0060.01617.00
7.2.130.0140.00816.54
7.2.120.0180.00317.00
7.2.110.0170.00316.67
7.2.100.0100.01016.79
7.2.90.0120.00816.55
7.2.80.0250.00416.41
7.2.70.0170.00616.82
7.2.60.0200.00816.84
7.2.50.0190.00316.31
7.2.40.0170.01016.29
7.2.30.0100.00716.71
7.2.20.0170.01017.06
7.2.10.0140.00716.88
7.2.00.0150.01518.37
7.1.250.0130.00315.78
7.1.200.0060.00615.75
7.1.100.0040.01318.04
7.1.70.0040.00417.05
7.1.60.0150.00719.32
7.1.50.0060.01617.19
7.1.00.0030.07322.75
7.0.200.0000.00916.80
7.0.140.0030.07322.28
7.0.60.0030.04320.18
7.0.50.0100.05018.14
7.0.40.0030.05320.40
7.0.30.0270.07320.45
7.0.20.0170.07320.25
7.0.10.0100.06320.59
7.0.00.0130.07720.34
5.6.210.0100.07720.68
5.6.200.0070.08318.31
5.6.190.0070.04020.66
5.6.180.0270.07320.74
5.6.170.0470.06020.83
5.6.160.0070.08320.73
5.6.150.0070.06018.36
5.6.140.0030.08318.47
5.6.130.0030.09318.32
5.6.120.0100.08321.23
5.6.110.0070.08321.35
5.6.100.0100.04321.29
5.6.90.0000.05321.34
5.6.80.0030.04020.71
5.5.350.0100.07720.67
5.5.340.0070.07718.15
5.5.330.0100.05320.38
5.5.320.0400.06020.54
5.5.310.0230.08320.44
5.5.300.0100.03718.17
5.5.290.0030.06018.12
5.5.280.0030.06721.17
5.5.270.0000.07320.95
5.5.260.0200.06720.99
5.5.250.0230.06320.88
5.5.240.0200.07720.49
5.4.450.1000.06719.85
5.4.440.1000.06719.86
5.4.430.0770.06319.57
5.4.420.0630.00019.86
5.4.410.0630.00019.59
5.4.400.0630.00019.26
5.4.390.0630.00019.19
5.4.380.0630.00019.26
5.4.370.0600.00019.34
5.4.360.0630.00019.26
5.4.350.0630.00019.26
5.4.340.0060.03712.05
5.4.320.0080.03612.55
5.4.310.0050.03912.54
5.4.300.0050.04112.54
5.4.290.0030.04212.55
5.4.280.0060.03512.44
5.4.270.0060.03712.44
5.4.260.0060.03812.44
5.4.250.0040.04212.44
5.4.240.0080.03412.45
5.4.230.0070.03712.44
5.4.220.0060.03712.43
5.4.210.0070.03512.43
5.4.200.0050.04212.44
5.4.190.0110.03112.43
5.4.180.0060.03612.43
5.4.170.0060.03812.43
5.4.160.0060.04112.43
5.4.150.0070.03612.43
5.4.140.0050.03912.12
5.4.130.0080.03612.10
5.4.120.0090.04912.06
5.4.110.0070.05012.06
5.4.100.0060.03812.05
5.4.90.0070.03712.05
5.4.80.0110.03412.05
5.4.70.0100.03112.05
5.4.60.0050.03712.05
5.4.50.0080.03412.05
5.4.40.0060.03512.04
5.4.30.0070.03812.04
5.4.20.0070.03512.04
5.4.10.0090.03212.03
5.4.00.0090.03511.53
5.3.290.0060.04012.80
5.3.280.0090.03512.72
5.3.270.0070.03912.73
5.3.260.0060.04012.73
5.3.250.0070.04012.73
5.3.240.0050.03912.73
5.3.230.0070.03812.73
5.3.220.0050.04012.70
5.3.210.0070.04612.70
5.3.200.0080.04012.69
5.3.190.0080.04512.70
5.3.180.0040.04212.69
5.3.170.0040.03912.69
5.3.160.0030.04412.70
5.3.150.0090.04012.69
5.3.140.0060.04212.68
5.3.130.0030.04412.68
5.3.120.0070.04212.68
5.3.110.0070.03712.68
5.3.100.0060.03712.16
5.3.90.0080.03512.14
5.3.80.0050.03712.14
5.3.70.0080.03512.14
5.3.60.0060.03612.13
5.3.50.0050.03612.07
5.3.40.0080.03312.07
5.3.30.0050.03612.03
5.3.20.0060.03611.82
5.3.10.0050.03511.77
5.3.00.0070.03711.77
5.2.170.0040.0359.27
5.2.160.0050.0319.27
5.2.150.0050.0339.27
5.2.140.0110.0269.27
5.2.130.0040.0309.23
5.2.120.0070.0289.23
5.2.110.0040.0349.23
5.2.100.0060.0309.23
5.2.90.0020.0329.23
5.2.80.0090.0309.23
5.2.70.0100.0359.23
5.2.60.0040.0309.18
5.2.50.0030.0329.14
5.2.40.0070.0279.13
5.2.30.0070.0289.09
5.2.20.0060.0329.09
5.2.10.0060.0289.00
5.2.00.0010.0338.87
5.1.60.0050.0238.15
5.1.50.0040.0258.15
5.1.40.0040.0258.14
5.1.30.0050.0258.48
5.1.20.0050.0278.51
5.1.10.0070.0238.23
5.1.00.0040.0268.23
5.0.50.0040.0236.72
5.0.40.0030.0206.57
5.0.30.0060.0306.39
5.0.20.0050.0196.37
5.0.10.0030.0206.35
5.0.00.0020.0346.34
4.4.90.0020.0164.78
4.4.80.0020.0164.75
4.4.70.0030.0154.75
4.4.60.0040.0144.76
4.4.50.0050.0144.77
4.4.40.0030.0254.72
4.4.30.0020.0174.76
4.4.20.0030.0154.84
4.4.10.0030.0154.85
4.4.00.0050.0244.76
4.3.110.0040.0144.67
4.3.100.0030.0154.66
4.3.90.0020.0154.64
4.3.80.0020.0244.64
4.3.70.0050.0124.64
4.3.60.0030.0144.64
4.3.50.0020.0174.63
4.3.40.0030.0234.59
4.3.30.0000.0183.41
4.3.20.0010.0173.38
4.3.10.0040.0153.33
4.3.00.0130.0208.12

preferences:
42.66 ms | 400 KiB | 5 Q