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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 131
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Math.sqrt()
35345936.0 Ops/sec
Binary search sqrt
1561422.1 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);