Math.hypot vs Math.sqrt

Benchmark created on


Setup

var i, tmp, x = 55, y = 66;

Test runner

Ready to run.

Testing in
TestOps/sec
Math.sqrt operation
// Math.sqrt operation
i = 0;
tmp = 0;
while(i++ < 2_000_000){
    tmp += Math.sqrt(x*x + y*y)
}

ready
Math.hypot
// Math.hypot
i = 0;
tmp = 0;
while(i++ < 2_000_000){
    tmp += Math.hypot(x, y)
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.