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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser:
Chrome 139
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
Table lookup
126416648.0 Ops/sec
Math.pow
134928512.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);