Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Chrome 85
Windows
Desktop
4 years ago
Test name Executions per second
sin 3.5 Ops/sec
cos 3.5 Ops/sec
tan 3.4 Ops/sec
asin 3.4 Ops/sec
acos 3.6 Ops/sec
atan 3.5 Ops/sec
atan2 2.3 Ops/sec
Script Preparation code:
x
 
var N = 1000000;
var x = new Float32Array(N);
var y = new Float32Array(N);
var theta = new Float32Array(N);
for (var i = 0; i < N; ++i) {
    x[i] = 100* Math.random();
    y[i] = 100* Math.random();
}
for (var i = 0; i < N; ++i) {
    theta[i] = 2 * Math.PI * Math.random();
}
Tests:
  • sin

     
    var fn = Math.sin;
    for (var i = 0; i < N; ++i) { fn(theta[i]); }
  • cos

     
    var fn = Math.cos;
    for (var i = 0; i < N; ++i) { fn(theta[i]); }
  • tan

     
    var fn = Math.tan;
    for (var i = 0; i < N; ++i) { fn(theta[i]); }
  • asin

     
    var fn = Math.asin;
    for (var i = 0; i < N; ++i) { fn(x[i]); }
  • acos

     
    var fn = Math.acos;
    for (var i = 0; i < N; ++i) { fn(x[i]); }
  • atan

     
    var fn = Math.atan;
    for (var i = 0; i < N; ++i) { fn(x[i]); }
  • atan2

     
    var fn = Math.atan;
    for (var i = 0; i < N; ++i) { fn(x[i], y[i]); }