Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134
Mac OS X 10.15.7
Desktop
12 days ago
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
Script Preparation code:
AخA
 
// 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));
Tests:
  • Power function (small number)

     
    smallNumber*smallNumber;
  • Power function (large number)

     
    largeNumber*largeNumber;
  • Power function (very large number)

     
    veryLargeNumber*veryLargeNumber;
  • Square root function (small number)

     
    Math.sqrt(smallNumber);
  • Square root function (large number)

     
    Math.sqrt(largeNumber);
  • Square root function (very large number)

     
    Math.sqrt(veryLargeNumber);