Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
math pow vs multiply (with few extra variants)
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/139.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 139
Operating system:
Android
Device Platform:
Mobile
Date tested:
8 months ago
Test name
Executions per second
pow
81014280.0 Ops/sec
mult
84692392.0 Ops/sec
pow2 bitwise
52763012.0 Ops/sec
pow2 summ
25263218.0 Ops/sec
pow2 multiplication
44947520.0 Ops/sec
pow (multiplication in for loop)
74723288.0 Ops/sec
Script Preparation code:
function powNaive(x, y) { if (!y) return 1; let tmp = x; for (let i = 1; i < y; i++) { tmp *= x; } return tmp; } // from https://codereview.stackexchange.com/a/217369 function pow2B(x, y) { if (y < 2) { return y ? x : 1 } if (y & 1) { return x * pow2B(x, y & 0x7FFFFFFE)} const p = pow2B(x, y >> 1); return p * p; } // other two functions from the same stackexchange post function pow(x, y) { if (!y) { return 1 } let tmp = res = x; for (let i = 1; i < y; i++) { for (let j = 1; j < x; j++) { tmp += res } res = tmp; } return res; } function pow2(x, y) { if (!y) { return 1; } if (y % 2) { return x * pow2(x, y - 1); } const p = pow2(x, y/2); return p * p; }
Tests:
pow
var x = Math.pow(54,2);
mult
var y = 54*54
pow2 bitwise
var y = pow2B(54, 2)
pow2 summ
var y = pow(54, 2)
pow2 multiplication
var y = pow2(54, 2)
pow (multiplication in for loop)
var y = powNaive(54, 2)