Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.pow(2,n) vs Table lookup?
Which is faster: Table lookup or Math.pow(2,10)?
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
Table lookup
75216416.0 Ops/sec
Math.pow
80905760.0 Ops/sec
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);