Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
trigata
(version: 0)
Comparing performance of:
native vs alt vs alt2 vs alt3 vs alt4 vs alt5
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function rand(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function angle(x, y) { let result = Math.atan(y / x); if (x < 0) { result += Math.PI; } else if (y < 0) { result += 2 * Math.PI; } return result; } function angle2(x, y) { if (x == 0) return (y == 0) ? 0 : (y > 0 ? Math.PI/2 : -Math.PI/2) var atan_xy = Math.atan(y / x) if (x > 0) return atan_xy else // x < 0 return atan_xy + (y < 0 ? -Math.PI : Math.PI) } function myAtan2(a, b) { var atan2val; if (b > 0) { atan2val = Math.atan(a/b); } else if ((b < 0) && (a >= 0)) { atan2val = Math.atan(a/b) + Math.PI; } else if ((b < 0) && (a < 0)) { atan2val = Math.atan(a/b) - Math.PI; } else if ((b = 0) && (a > 0)) { atan2val = Math.PI / 2; } else if ((b = 0) && (a < 0)) { atan2val = 0 - (Math.PI / 2 ); } else if ((b = 0) && (a = 0)) { atan2val = 1000; } return atan2val; } function matan2(y, x){ const c1 = Math.PI / 4; const c2 = Math.PI * 3 / 4; if (y == 0 && x == 0){ return 0; } const abs_y = Math.abs(y); let angle; if (x >= 0){ angle = c1 - c1 * ((x - abs_y) / (x + abs_y)); } else { angle = c2 - c1 * ((x + abs_y) / (abs_y - x)); } if (y < 0){ return -angle; } return angle; } function atandd(y, x) { const ONEQTR_PI = Math.PI / 4.0; const THRQTR_PI = 3.0 * Math.PI / 4.0; let r, angle; let abs_y = Math.abs(y) + 0.0000000001; if ( x < 0 ) { r = (x + abs_y) / (abs_y - x); angle = THRQTR_PI; } else { r = (x - abs_y) / (x + abs_y); angle = ONEQTR_PI; } angle += (0.1963 * r * r - 0.9817) * r; if ( y < 0 ) return( -angle ); else return( angle ); }
Tests:
native
var xO = rand(1, 1000); var yO = rand(1, 1000); Math.atan(yO, xO);
alt
var xT = rand(1, 1000); var yT = rand(1, 1000); angle(xT, yT);
alt2
var xD = rand(1, 1000); var yD = rand(1, 1000); angle2(xD, yD);
alt3
var xC = rand(1, 1000); var yC = rand(1, 1000); myAtan2(xC, yC);
alt4
var xZ = rand(1, 1000); var yZ = rand(1, 1000); matan2(xZ, yZ);
alt5
var xU = rand(1, 1000); var yU = rand(1, 1000); atandd(yU, xU)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
native
alt
alt2
alt3
alt4
alt5
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It appears that you're sharing benchmark results from a test of various implementations of the `atandd` and `matan2` functions, as well as an alternative implementation called `myAtan2`. The tests are run on different devices (iPhone) with the Chrome Mobile browser. To answer your question: * The native implementation (`native`) has the highest execution speed, indicating that it is the fastest. * `alt3` and `alt5` have similar execution speeds, but slightly slower than `native`. * `alt4` has a lower execution speed compared to the others. * `alt2` and `alt` are slower than the native implementation. Please note that these results may vary depending on the specific test setup, device configuration, and other factors.
Related benchmarks:
trigata
trigata
trigata
trigata
Comments
Confirm delete:
Do you really want to delete benchmark?