Math.hypot (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Math.hypot
var x = 0;
for (i = 0; i < 1e6; i++)
    x = Math.hypot(x, 1);
if (Math.abs(x - 1e3) > 10)
    throw ("FAIL: " + x);
ready
sqrt + *
var x = 0;
for (i = 0; i < 1e6; i++)
    x = Math.sqrt(x * x + 1 * 1);
if (Math.abs(x - 1e3) > 10)
    throw ("FAIL: " + x);
ready
sqrt + pow
var x = 0;
for (i = 0; i < 1e6; i++)
    x = Math.sqrt(Math.pow(x, 2) + Math.pow(1, 2));
if (Math.abs(x - 1e3) > 10)
    throw ("FAIL: " + x);
ready

Revisions

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