Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.sqrt() vs. Binary search sqrt
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.sqrt()
8634507.0 Ops/sec
Binary search sqrt
2253998.2 Ops/sec
Script Preparation code:
function sqrt(x) { if (x < 0.0) return NaN; if (x < 1.0) return 1.0 / sqrt(1.0 / x); let xhi = x; let xlo = 0.0; let guess = x / 2.0; let next; while ((guess * guess) != x) { if ((guess * guess) > x) xhi = guess; else xlo = guess; if ((next = (xhi + xlo) / 2.0) == guess) break; guess = next; } return guess; }
Tests:
Math.sqrt()
Math.sqrt(Math.random() * 1000000);
Binary search sqrt
sqrt(Math.random() * 1000000);