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 |
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();
}
var fn = Math.sin;
for (var i = 0; i < N; ++i) { fn(theta[i]); }
var fn = Math.cos;
for (var i = 0; i < N; ++i) { fn(theta[i]); }
var fn = Math.tan;
for (var i = 0; i < N; ++i) { fn(theta[i]); }
var fn = Math.asin;
for (var i = 0; i < N; ++i) { fn(x[i]); }
var fn = Math.acos;
for (var i = 0; i < N; ++i) { fn(x[i]); }
var fn = Math.atan;
for (var i = 0; i < N; ++i) { fn(x[i]); }
var fn = Math.atan;
for (var i = 0; i < N; ++i) { fn(x[i], y[i]); }