Script Preparation code:
AخA
 
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);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Table lookup
    Math.pow
    bitwise (1 << n)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36
Chrome Mobile 113 on Android
View result in a separate tab
Test name Executions per second
Table lookup 273325.5 Ops/sec
Math.pow 145618.7 Ops/sec
bitwise (1 << n) 6254165.0 Ops/sec