Test name | Executions per second |
---|---|
Power function (small number) | 2765522.8 Ops/sec |
Power function (large number) | 2740803.5 Ops/sec |
Power function (very large number) | 2766872.2 Ops/sec |
Square root function (small number) | 2777815.0 Ops/sec |
Square root function (large number) | 2765826.5 Ops/sec |
Square root function (very large number) | 2758241.5 Ops/sec |
// Javascript uses floats for numbers. Generaate some numbers in advance.
var smallNumber = Math.pow(2, 7) + Math.floor(Math.random() * Math.pow(2,7));
var largeNumber = Math.pow(2, 30) + Math.floor(Math.random() * Math.pow(2,30));
var veryLargeNumber = Math.pow(2, 60) + Math.floor(Math.random() * Math.pow(2,60));
Math.pow(smallNumber, 2);
Math.pow(largeNumber, 2);
Math.pow(veryLargeNumber, 2);
Math.sqrt(smallNumber);
Math.sqrt(largeNumber);
Math.sqrt(veryLargeNumber);