Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Chrome 94
Linux
Desktop
3 years ago
Test name Executions per second
Right shift 14431.3 Ops/sec
Divide and floor 644.0 Ops/sec
Divide and floor 2 11045.2 Ops/sec
Script Preparation code:
AخA
 
var arr = new Array(10000).fill(0).map(() => Math.random() * 10);
Tests:
  • Right shift

     
    arr.map(n => n >> 1);
  • Divide and floor

     
    arr.map(n => Math.floor(n / 2));
  • Divide and floor 2

     
    arr.map(n => ~~(n / 2));