Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Leetcode Pow vs Math.pow syntax
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
My Pow
63011.0 Ops/sec
Math.Pow
534498.2 Ops/sec
Tests:
My Pow
function myPow(x, n) { function calc_power(x, n) { if (x === 0) { return 0; } if (n === 0) { return 1; } let res = calc_power(x, Math.floor(n / 2)); res = res * res; if (n % 2 === 1) { return res * x; } return res; } let ans = calc_power(x, Math.abs(n)); if (n >= 0) { return ans; } return 1 / ans; } myPow(2, 3) myPow(5, 0) myPow(7, 1) myPow(-3, 4) myPow(-2, 3) myPow(0, 5) myPow(0, 0) myPow(0, -2) myPow(1, 100) myPow(10, 2) myPow(0.5, 10) myPow(-2, 10) myPow(2, -3) myPow(1.5, 2) myPow(-3, -2) myPow(99, 100000000000)
Math.Pow
Math.pow(2, 3) Math.pow(5, 0) Math.pow(7, 1) Math.pow(-3, 4) Math.pow(-2, 3) Math.pow(0, 5) Math.pow(0, 0) Math.pow(1, 100) Math.pow(10, 2) Math.pow(0.5, 10) Math.pow(-2, 10) Math.pow(2, -3) Math.pow(1.5, 2) Math.pow(-3, -2) Math.pow(99, 100000000000)