Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Math.pow(2,n) vs Table lookup?
(version: 6)
Which is faster: Table lookup or Math.pow(2,10)?
Comparing performance of:
Table lookup vs Math.pow
Created:
8 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var POWERS = [ 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768, 65536,131072,262144,524288,1048576,2097152 ];
Tests:
Table lookup
let p = 15; let x; if (p > 20) { x = Math.pow(2,p); } else { x = POWERS[20]; }
Math.pow
let p = 15; let x; x = Math.pow(2,p);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Table lookup
Math.pow
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
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/OS:
Chrome Mobile 139 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Table lookup
75216416.0 Ops/sec
Math.pow
80905760.0 Ops/sec
Related benchmarks:
Math.pow vs Exponentiation vs Multiplication
Math.pow vs Exponentiation vs Multiplication pow 4
Math.pow(2,n) vs Table lookup vs bitwise
Math.pow vs Exponentiation vs Multiplication 2
Comments
Confirm delete:
Do you really want to delete benchmark?