Hypot vs Sqrt

Benchmark created on


Setup

let total = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
sqrt
for(let i = 0; i < 1000; i++) {
	let x = Math.random();
	let y = Math.random();
	total += Math.sqrt(x * x + y * y);
}
ready
hypot
for(let i = 0; i < 1000; i++) {
	let x = Math.random();
	let y = Math.random();
	total += Math.hypot(x, y);
}
ready

Revisions

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