Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Math.sqrt()
75.4M/s
Binary search sqrt
2.9M/s
View exact numbers
Test name
Executions per second
✓
Math.sqrt()
75,405,400 Ops/sec
Binary search sqrt
2,903,022 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);