Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.pow(x,0.5) vs Math.sqrt(x) vs (x ** 0.5) reduce sum
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/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Math.sqrt
1258.8 Ops/sec
sqrt with Math.pow
1303.4 Ops/sec
sqrt with ** 0.5
9809.6 Ops/sec
Script Preparation code:
var numbers = Array.from(Array(10000), (_,x) => (Math.random()*x));
Tests:
Math.sqrt
const sum = numbers.map(number => Math.sqrt(number)).reduce((a, b) => a + b, 0) console.log(sum)
sqrt with Math.pow
const sum = numbers.map(number => Math.pow(number, 0.5)).reduce((a, b) => a + b, 0) console.log(sum)
sqrt with ** 0.5
const sum = numbers.map(number => number ** 0.5).reduce((a, b) => a + b, 0) console.log(sum)