Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.pow(2,n) vs Table lookup vs bitwise
Which is faster: Table lookup or Math.pow(2,value) or bitwise operation (1 << value)?
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
18919326.0 Ops/sec
Math.pow
16574829.0 Ops/sec
bitwise (1 << n)
49788644.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,4194304,8388608,16777216,33554432 ];
Tests:
Table lookup
let cnt = POWERS.length; let x; for(let i =0;i<cnt;i++){ x = POWERS[i]; }
Math.pow
let cnt = POWERS.length; let x; for(let i =0;i<cnt;i++){ x = Math.pow(2,i); }
bitwise (1 << n)
let cnt = POWERS.length; let x; for(let i =0;i<cnt;i++){ x = (1 << i); }