Test name | Executions per second |
---|---|
Power function (small number) | 230288224.0 Ops/sec |
Power function (large number) | 223607904.0 Ops/sec |
Power function (very large number) | 230066000.0 Ops/sec |
Square root function (small number) | 220232768.0 Ops/sec |
Square root function (large number) | 240716576.0 Ops/sec |
Square root function (very large number) | 207087552.0 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));
smallNumber*smallNumber;
largeNumber*largeNumber;
veryLargeNumber*veryLargeNumber;
Math.sqrt(smallNumber);
Math.sqrt(largeNumber);
Math.sqrt(veryLargeNumber);