3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CTransformator_2 { //public: function CTransformator() { $this->ro = 3.1415926535897932384626433832795 / 180; $this->InitPlane(); $this->InitEllipse(); } function Destroy() { } // default plane configuration: "TM-" function InitPlane($deg1 = 24.0, $min1 = 0.0, $sec1 = 0.0, $deg2 = 0.0, $min2 = 0.0, $sec2 = 0.0, $_cf3 = -6000000, $_cf4 = 500000, $_cf5 = 0, $_cf6 = 0.9996) { $this->cf1 = ($deg1 + $min1 / 60.0 + $sec1 / 3600.0) * $this->ro; $this->cf2 = ($deg2 + $min2 / 60.0 + $sec2 / 3600.0) * $this->ro; $this->cf3 = $_cf3; $this->cf4 = $_cf4; $this->cf5 = $_cf5; $this->cf6 = $_cf6; } // default elipse GRS80 = 6378137,298.2572221 function InitEllipse($_a = 6378137.0, $_alfa = 298.2572221) { $this->a = $_a; $this->alfa = $_alfa; $b = $this->a - $this->a / $this->alfa; $this->e2 = 1.0 - ($b * $b) / ($this->a * $this->a); $this->ep2 = ($this->a * $this->a) / ($b * $b) - 1.0; // for function mer() speed optimization $e2_2 = $this->e2 * $this->e2; $e2_3 = $e2_2 * $this->e2; $this->AA = 1.0 + (3.0/4.0)*$this->e2 + (45.0/64.0)*$e2_2 + (175.0/256.0)*$e2_3; $this->BB = ((3.0/4.0)*$this->e2 + (15.0/16.0)*$e2_2 + (525.0/512.0)*$e2_3) / 2.0; $this->CC = ((15.0/64.0)*$e2_2 + (105.0/256.0)*$e2_3) / 4.0; $this->DD = (( 35.0/512.0)*$e2_3) / 6.0; $this->a1e2 = $this->a*(1.0-$this->e2); } function GaussTU($B, $L, &$x, &$y, &$gam, &$merr) { $B *= $this->ro; $L *= $this->ro; $sinB = sin($B); $cosB = cos($B); $t = $sinB / $cosB; //tan(B); $t2 = $t * $t; $nn = $this->N($sinB); $M1 = $cosB * $cosB; $M2 = $M1 * $M1; $et2 = $this->ep2 * $M1; $et4 = $et2 * $et2; $X_L = $this->mer(0, $B); $l0 = $this->cf1; if ($this->cf2 > 0) { $l0 = abs($L - $this->cf1) + $this->cf2 / 2.0; $l0 = $this->IntPart($l0 / $this->cf2) * $this->cf2; if ($L < $this->cf1) $l0 = -$l0; $l0 += $this->cf1; } $ltd = $l0; // ------------------ WORK $lm = $L - $ltd; $lm2 = $lm * $lm; $lm4 = $lm2 * $lm2; $x = $X_L + ($lm2 / 2.0) * $nn * $sinB * $cosB * (1 + (($lm2 * $M1) / 12.0) * (5 - $t2 + 9*$et2 + 4*$et4) + (($lm4 * $M2) / 360.0) * (61 - 58*$t2 + $t2*$t2)); $y = $lm * $nn * $cosB * (1 + (($lm2 * $M1) / 6.0) * (1 - $t2 + $et2) + (($lm4 * $M2) / 120.0) * (5 - 18*$t2 + $t2*$t2 + 14*$et2 - 58*$et2*$t2)); $gam = $lm * $sinB * (1 + ($lm2/3.0) * $M1 * (1 + 3*$et2) + ($lm4/15.0) * $M2 * (2 - $t2)); $merr = 1 + ((1 + $et2) / 2.0) * $lm2 * $M1 + ((5 - 4*$t2) / 24.0) * $lm4 * $M2; $x = $x * $this->cf6 + $this->cf3; $y = $y * $this->cf6 + $this->cf4; if ($this->cf2 > 0) $y += $this->cf5 * ($ltd - $this->cf1) / $this->cf2; // ------------------ END OF WORK $merr *= $this->cf6; } function GaussPU($x, $y, &$B, &$L) { /*double Bx, dx, xa, yy, y2, y4, Mx, Mx2, Nx, Nx2, tx, tx2, eta2, dn;*/ $x = ($x - $this->cf3) / $this->cf6; $yy = $y - $this->cf4; $dn = 0; if ($this->cf5 > 0) { $dn = $this->IntPart($yy / $this->cf5 + (($yy < 0) ? -0.5 : +0.5)); $yy -= $dn * $this->cf5; } $yy /= $this->cf6; $y2 = $yy * $yy; $y4 = $y2 * $y2; // --------- Bx calculation ---------- $Bx = $x / $this->M(sin($x / $this->M(0) / 2.0)); $xa = $this->mer(0, $Bx); // xa = meridiana loka garums $dx = $x - $xa; // delta x while (abs($dx) > 0.0000001) { $Bx += $dx / $this->M(sin($Bx)); // jauna Bx vertiba $xa = $this->mer(0, $Bx); // xa = meridiana loka garums $dx = $x - $xa; // cikla kontroles aprekins } // --------- tx un eta aprekins ---------- $cosBx = cos($Bx); $sinBx = sin($Bx); $eta2 = $this->ep2 * $cosBx * $cosBx; $tx = $sinBx / $cosBx; // tan(Bx) $tx2 = $tx * $tx; // --------- Mx un Nx aprekins ---------- $Mx = $this->M($sinBx); $Mx2 = $Mx * $Mx; $Nx = $this->N($sinBx); $Nx2 = $Nx * $Nx; // --------- B aprekins ---------- $B = $Bx - ($y2 / (2*$Mx*$Nx)) * $tx * (1 - ($y2 / (12*$Nx2)) * (5 + 3*$tx2 + $eta2 - 9*$eta2 *$tx2) + ($y4 / (360*$Nx2*$Nx2)) * (61 + 90*$tx2 + 45*$tx2*$tx2)); // --------- L aprekins ---------- $L = ($yy / ($Nx*$cosBx)) * (1 - ($y2 / (6*$Nx2)) * (1 + 2*$tx2 + $eta2) + ($y4 / (120*$Nx2*$Nx2)) * (5 + 28*$tx2 + 24*$tx2*$tx2 + 6*$eta2 + 8*$eta2 *$tx2)); // Izmainit geodezisko garumu $L += $this->cf1; if ($this->cf2 > 0) $L += $dn * $this->cf2; $L /= $this->ro; $B /= $this->ro; } //private: function IntPart($d) { return ($d >= 0) ? floor($d) : ceil($d); } // round towards zero function W($sinB) { return sqrt(1-$this->e2*$sinB*$sinB); } function M($sinB) { $r = $this->W($sinB); return $this->a*(1-$this->e2)/($r*$r*$r); } function N($sinB) { return $this->a/$this->W($sinB); } function mer($b1, $b2) { if ($b1 == 0) // optimization return $this->a1e2 * ($this->AA*$b2 - $this->BB*sin(2*$b2) + $this->CC*sin(4*$b2) - $this->DD*sin(6*$b2)); else return $this->a1e2 * ($this->AA*($b2-$b1) - $this->BB*(sin(2*$b2)-sin(2*$b1)) + $this->CC*(sin(4*$b2)-sin(4*$b1)) - $this->DD*(sin(6*$b2)-sin(6*$b1))); } var $a, $alfa, $e2, $ep2; var $cf1, $cf2, $cf3, $cf4, $cf5, $cf6; var $AA, $BB, $CC, $DD, $a1e2; // for function mer() speed optimization var $ro; } function eho($what, $label) { echo "\n\n" . $label . ': '; dump($what); echo "\n\n"; } function dump() { $args = func_get_args(); return call_user_func_array('var_dump', $args); } function ehobool($b, $label) { eho($b ? 'true' : 'false', $label); } function f($lat, $lon, &$x, &$y) { $x = 500019.68325692; $y = 500019.68325692; } function g($lat, $lon, &$x, &$y) { if ($lat == 0 || $lon == 0 || abs($lat) >= 360 || abs($lon) >= 360) { $x = 0; $y = 0; } else { $gam = NULL; $merr = NULL; $t = new CTransformator_2(); // For some UNKNOWN REASON x and y has been exchanged somewhere! $t->GaussTU($lat,$lon,$y,$x,$gam,$merr); $t->Destroy(); if ($lat < 45 && $lon > 38) { $x = $x - 1760.18; $y = $y - 239.29; } } } function h($lat, $lon, &$x, &$y) { f($lat, $lon, $x, $y); } function CalculateRegularFenceCoords ($fCentreLat, $fCentreLon, $fRadius, $iVertices) { //$a = shell_exec( // "node $shell_scripts_path/nodejs/calculate_regular_fence.js --www_path=$source_www_path " . // "--lat=$fCentreLat --lon=$fCentreLon --radius=$fRadius --vertices=$iVertices" //); //eho($a, 'shell_exec'); $a = '{"lats":["56.998210","56.998210","56.998279","56.998414","56.998610","56.998859","56.999152","56.999478","56.999824","57.000176","57.000522","57.000848","57.001141","57.001390","57.001586","57.001721","57.001789","57.001789","57.001721","57.001586","57.001390","57.001141","57.000848","57.000522","57.000176","56.999824","56.999478","56.999152","56.998859","56.998610","56.998414","56.998279","56.998210"],"lons":["24.000324","23.999676","23.999042","23.998444","23.997906","23.997448","23.997088","23.996841","23.996714","23.996714","23.996841","23.997088","23.997448","23.997906","23.998444","23.999042","23.999676","24.000324","24.000958","24.001556","24.002094","24.002552","24.002912","24.003159","24.003286","24.003286","24.003159","24.002912","24.002552","24.002094","24.001556","24.000958","24.000324"]}'; $aFenceCoords = json_decode($a, true); foreach ($aFenceCoords['lats'] as $i => $fLat) { $aFenceCoords['xes'][$i] = 500019.68325692; g($aFenceCoords['lats'][$i], $aFenceCoords['lons'][$i], $aFenceCoords['xes'][$i], $aFenceCoords['ys'][$i]); } return $aFenceCoords; } $actual = CalculateRegularFenceCoords(57, 24, 200, 32); unset($actual['lats'], $actual['lons'], $actual['ys']); for ($i = 0; $i <= 31; ++$i) { unset($actual['xes'][$i]); } eho($actual, '$actual'); ehobool($actual["xes"][32] == 500019.68325692, '$actual["xes"][32] == 500019.68325692'); eho($actual["xes"][32], '$actual["xes"][32]'); $actual= array( "xes"=> array( 32=> 500019.68325692 ) ); eho($actual, '$actual'); ehobool($actual["xes"][32] == 500019.68325692, '$actual["xes"][32] == 500019.68325692'); eho($actual["xes"][32], '$actual["xes"][32]');

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.0150.00018.18
8.3.50.0140.00722.04
8.3.40.0110.00419.04
8.3.30.0000.01519.49
8.3.20.0030.00620.50
8.3.10.0060.00320.83
8.3.00.0060.00618.00
8.2.180.0120.00317.00
8.2.170.0110.00722.96
8.2.160.0060.01320.83
8.2.150.0040.00424.18
8.2.140.0100.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00422.26
8.2.110.0060.00320.78
8.2.100.0000.01218.09
8.2.90.0030.00519.61
8.2.80.0000.01018.00
8.2.70.0030.00718.00
8.2.60.0090.00018.18
8.2.50.0030.00518.07
8.2.40.0040.00418.41
8.2.30.0030.00519.74
8.2.20.0040.00418.06
8.2.10.0030.00618.34
8.2.00.0040.00418.11
8.1.280.0040.01225.92
8.1.270.0080.00024.09
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00022.50
8.1.230.0060.00622.36
8.1.220.0000.00918.03
8.1.210.0030.00618.77
8.1.200.0030.00717.73
8.1.190.0000.00817.48
8.1.180.0000.00818.10
8.1.170.0040.00418.63
8.1.160.0080.00022.32
8.1.150.0040.00419.09
8.1.140.0080.00017.79
8.1.130.0070.00018.18
8.1.120.0090.00017.66
8.1.110.0000.00817.70
8.1.100.0040.00417.65
8.1.90.0070.00017.64
8.1.80.0030.00617.63
8.1.70.0080.00017.71
8.1.60.0030.00617.84
8.1.50.0030.00617.84
8.1.40.0030.00817.79
8.1.30.0030.00617.97
8.1.20.0080.00017.89
8.1.10.0000.00817.84
8.1.00.0080.00017.82
8.0.300.0030.00618.77
8.0.290.0050.00317.00
8.0.280.0070.00018.66
8.0.270.0040.00417.52
8.0.260.0040.00420.37
8.0.250.0000.00717.19
8.0.240.0030.00817.20
8.0.230.0070.00017.19
8.0.220.0000.00817.21
8.0.210.0000.00717.17
8.0.200.0000.00817.21
8.0.190.0040.00417.25
8.0.180.0040.00417.20
8.0.170.0050.00317.18
8.0.160.0000.00817.26
8.0.150.0040.00417.05
8.0.140.0040.00417.20
8.0.130.0030.00313.64
8.0.120.0060.00317.09
8.0.110.0000.00817.15
8.0.100.0050.00317.12
8.0.90.0000.00817.30
8.0.80.0090.00617.19
8.0.70.0000.00817.22
8.0.60.0060.00317.20
8.0.50.0080.00017.14
8.0.30.0120.00717.26
8.0.20.0100.01217.45
8.0.10.0050.00317.39
8.0.00.0120.00816.93
7.4.330.0050.00015.00
7.4.320.0000.00816.76
7.4.300.0000.00616.68
7.4.290.0040.00416.88
7.4.280.0030.00516.88
7.4.270.0030.00516.82
7.4.260.0070.00016.87
7.4.250.0030.00616.86
7.4.240.0030.00516.90
7.4.230.0040.00416.89
7.4.220.0130.01616.92
7.4.210.0080.00816.85
7.4.200.0050.00216.99
7.4.160.0110.00616.64
7.4.150.0080.01117.40
7.4.140.0130.01017.86
7.4.130.0090.00916.72
7.4.120.0090.00916.85
7.4.110.0080.01516.86
7.4.100.0150.00816.75
7.4.90.0060.01216.71
7.4.80.0090.01119.39
7.4.70.0070.01716.76
7.4.60.0100.00716.86
7.4.50.0090.00016.45
7.4.40.0090.00916.89
7.4.30.0150.00316.69
7.4.00.0060.00815.17
7.3.330.0030.00313.64
7.3.320.0060.00013.61
7.3.310.0000.00716.67
7.3.300.0040.00416.61
7.3.290.0180.00016.52
7.3.280.0070.01116.57
7.3.270.0040.01417.40
7.3.260.0090.00916.57
7.3.250.0120.00616.55
7.3.240.0100.01416.54
7.3.230.0070.01416.77
7.3.210.0070.01116.57
7.3.200.0140.00319.39
7.3.190.0070.01116.61
7.3.180.0090.00916.57
7.3.170.0120.01216.89
7.3.160.0090.00916.73
7.3.120.0090.00915.30
7.3.110.0040.01415.33
7.3.100.0060.00915.15
7.3.90.0030.01014.87
7.3.80.0100.00615.15
7.3.70.0030.00914.81
7.3.60.0030.01214.95
7.3.50.0050.00814.88
7.3.40.0080.00415.11
7.3.30.0060.00914.88
7.3.20.0040.01217.02
7.3.10.0100.00616.38
7.3.00.0110.00516.71
7.2.330.0180.00016.91
7.2.320.0090.01216.86
7.2.310.0110.00817.10
7.2.300.0070.01016.73
7.2.290.0030.01316.95
7.2.250.0090.01215.48
7.2.240.0030.01715.37
7.2.230.0070.00915.57
7.2.220.0030.01215.31
7.2.210.0030.01415.29
7.2.200.0030.00715.50
7.2.190.0080.00415.26
7.2.180.0090.00315.39
7.2.170.0030.00915.33
7.2.130.0080.01016.87
7.2.120.0110.01216.91
7.2.110.0110.01016.81
7.2.100.0080.01316.75
7.2.90.0160.00516.93
7.2.80.0110.01216.89
7.2.70.0110.01016.62
7.2.60.0090.00917.09
7.2.50.0120.00416.66
7.2.40.0100.01116.77
7.2.30.0110.00916.96
7.2.20.0140.00816.73
7.2.10.0110.00816.76
7.2.00.0120.01117.90
7.1.330.0080.00815.89
7.1.320.0070.01016.00
7.1.310.0030.00716.12
7.1.300.0000.01515.78
7.1.290.0110.00015.86
7.1.280.0070.00715.76
7.1.270.0040.00415.86
7.1.260.0090.00616.00
7.1.250.0040.01215.67
7.1.200.0030.00915.96
7.1.100.0070.01018.36
7.1.70.0040.00717.40
7.1.60.0060.01819.61
7.1.50.0090.01216.79
7.1.00.0130.07022.67
7.0.200.0000.00817.04
7.0.140.0070.07322.09
7.0.100.0330.06020.11
7.0.90.0030.08720.13
7.0.80.0070.04720.14
7.0.70.0100.08320.14
7.0.60.0130.07320.14
7.0.50.0070.07020.52
7.0.40.0070.09020.08
7.0.30.0070.08720.20
7.0.20.0030.08720.16
7.0.10.0030.06720.09
7.0.00.0030.07320.09
5.6.280.0070.06721.17
5.6.250.0170.07720.77
5.6.240.0100.05020.77
5.6.230.0130.08320.73
5.6.220.0100.06720.89
5.6.210.0000.06020.79
5.6.200.0100.06021.28
5.6.190.0100.06721.07
5.6.180.0070.07321.31
5.6.170.0100.08021.16
5.6.160.0130.05721.16
5.6.150.0130.08021.22
5.6.140.0000.06021.21
5.6.130.0130.04721.25
5.6.120.0030.05321.26
5.6.110.0070.07721.12
5.6.100.0070.05321.23
5.6.90.0030.07721.12
5.6.80.0100.05020.54
5.6.70.0130.07320.68
5.6.60.0070.07020.64
5.6.50.0100.07020.52
5.6.40.0070.07720.43
5.6.30.0070.07720.45
5.6.20.0070.08320.48
5.6.10.0070.08320.53
5.6.00.0100.07720.55
5.5.380.0130.08020.53
5.5.370.0230.06720.51
5.5.360.0070.08720.58
5.5.350.0030.09020.61
5.5.340.0100.08020.96
5.5.330.0100.08321.04
5.5.320.0100.07720.96
5.5.310.0130.04720.93
5.5.300.0130.07021.02
5.5.290.0030.07021.01
5.5.280.0070.08321.04
5.5.270.0070.08321.04
5.5.260.0200.06320.75
5.5.250.0100.07020.70
5.5.240.0100.04020.12
5.5.230.0100.07720.20
5.5.220.0100.05720.15
5.5.210.0070.06020.29
5.5.200.0200.06720.35
5.5.190.0030.04320.25
5.5.180.0030.05020.13
5.5.160.0170.07320.37
5.5.150.0130.06720.25
5.5.140.0130.07320.37
5.5.130.0030.04320.25
5.5.120.0070.05720.39
5.5.110.0130.06720.27
5.5.100.0100.06020.28
5.5.90.0130.07020.28
5.5.80.0030.08320.30
5.5.70.0230.03720.20
5.5.60.0070.04720.29
5.5.50.0000.04720.16
5.5.40.0000.05320.06
5.5.30.0030.04020.18
5.5.20.0130.03020.18
5.5.10.0100.03320.26
5.5.00.0100.03320.14
5.4.450.0070.04719.46
5.4.440.0170.06719.49
5.4.430.0030.05019.55
5.4.420.0030.08019.32
5.4.410.0130.06719.20
5.4.400.0170.04319.30
5.4.390.0000.05319.16
5.4.380.0170.06319.16
5.4.370.0100.07319.23
5.4.360.0100.06719.00
5.4.350.0130.05719.13
5.4.340.0030.06019.21
5.4.320.0030.08019.29
5.4.310.0070.07319.13
5.4.300.0070.07318.97
5.4.290.0070.06019.29
5.4.280.0030.04719.22
5.4.270.0030.05319.20
5.4.260.0000.05019.15
5.4.250.0170.06019.16
5.4.240.0030.08318.98
5.4.230.0130.05018.96
5.4.220.0030.05019.32
5.4.210.0000.04319.16
5.4.200.0000.04319.22
5.4.190.0030.04318.98
5.4.180.0070.03719.13
5.4.170.0130.03019.00
5.4.160.0000.04019.34
5.4.150.0030.04319.28
5.4.140.0030.03716.57
5.4.130.0000.04016.34
5.4.120.0000.03716.45
5.4.110.0070.05016.38
5.4.100.0030.03716.54
5.4.90.0030.04316.50
5.4.80.0100.06316.47
5.4.70.0030.04016.47
5.4.60.0030.05316.56
5.4.50.0030.06316.57
5.4.40.0070.04016.31
5.4.30.0030.05316.63
5.4.20.0030.06716.57
5.4.10.0070.06716.57
5.4.00.0030.07315.94

preferences:
44.05 ms | 401 KiB | 5 Q