Script Preparation code:
AخA
 
const N = 1e7;
const values = new Array(N).fill(0).map(() => [Math.random(), Math.random()]);
Tests:
  • sqrt

     
    for (let i = 0; i < N; i++) {
        Math.sqrt(values[i][0] ** 2 + values[i][1] ** 2);
    }
  • sqrt * direct

     
    for (let i = 0; i < N; i++) {
        Math.sqrt(values[i][0] * values[i][0] + values[i][1] * values[i][1]);
    }
  • hypot

     
    for (let i = 0; i < N; i++) {
        Math.hypot(values[i][0], values[i][1]);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    sqrt
    sqrt * direct
    hypot

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136 on Windows
View result in a separate tab
Test name Executions per second
sqrt 32.0 Ops/sec
sqrt * direct 32.7 Ops/sec
hypot 31.9 Ops/sec