Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
Chrome 88
Mac OS X 11.2.1
Desktop
3 years ago
Test name Executions per second
sin 8.1 Ops/sec
cos 8.1 Ops/sec
tan 8.1 Ops/sec
asin 8.2 Ops/sec
acos 8.1 Ops/sec
atan 8.2 Ops/sec
atan2 5.4 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]); }