Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
distance calculations
(version: 1)
Comparing performance of:
hypot vs sqrt vs sqrt + pow vs i*i vs pow
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function testHypot() { for (let i=0; i < 1000; i++){ for (let j=0; j < 1000; j++) { Math.hypot(i, j) } } } function testSqrt() { for (let i=0; i < 1000; i++){ for (let j=0; j < 1000; j++) { Math.sqrt(i*i+j*j) } } } function testSqrtAndPow() { for (let i=0; i < 1000; i++){ for (let j=0; j < 1000; j++) { Math.sqrt(Math.pow(i,2)+Math.pow(j,2)) } } } function testNoSqrt() { for (let i=0; i < 1000; i++){ for (let j=0; j < 1000; j++) { i*i+j*j } } } function testNoSqrtAndPow() { for (let i=0; i < 1000; i++){ for (let j=0; j < 1000; j++) { Math.pow(i,2)+Math.pow(j,2) } } }
Tests:
hypot
testHypot()
sqrt
testSqrt()
sqrt + pow
testSqrtAndPow()
i*i
testNoSqrt()
pow
testNoSqrtAndPow()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
hypot
sqrt
sqrt + pow
i*i
pow
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
21 days ago
)
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.5 Mobile/15E148 Safari/604.1
Browser/OS:
Mobile Safari 26 on iOS 18.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
hypot
154.4 Ops/sec
sqrt
3216.6 Ops/sec
sqrt + pow
3149.9 Ops/sec
i*i
2407.2 Ops/sec
pow
2598.5 Ops/sec
Related benchmarks:
Fast Sqrt
Fast Sqrt 2
Math.sqrt() vs Fast inverse sqrt
Inv Fast Sqrt
Inverse square root (fixed)
Fast Sqrt0
Sqrt vs Alpha max plus beta min algorithm vs lookup table vs **0.5
Effect of function calls in loops2
Math.hypot vs Math.sqrt
Comments
Confirm delete:
Do you really want to delete benchmark?