Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Leetcode Pow vs Math.pow
(version: 0)
Comparing performance of:
My Pow vs Math.Pow
Created:
one year ago
by:
Guest
Jump to the latest result
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));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
My Pow
Math.Pow
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?