`Math.hypot` versus manual length

Benchmark created on


Description

Compares the built-in Math.hypot function with manual three-dimensional length calculation.

Setup

const a = Math.floor(Math.random() * 10);
const b = Math.floor(Math.random() * 10);
const c = Math.floor(Math.random() * 10);

Test runner

Ready to run.

Testing in
TestOps/sec
`Math.hypot`
Math.hypot(a, b, c);
ready
Manual (multiplication operator)
Math.sqrt(a * a + b * b + c * c);
ready
Manual (exponentiation operator)
Math.sqrt(a ** 2 + b ** 2 + c ** 2);
ready

Revisions

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