Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0
Firefox 111
Mac OS X 10.15
Desktop
one year ago
Test name Executions per second
array slice 205299.4 Ops/sec
typedArray slice 164775.8 Ops/sec
array i/o 64657.2 Ops/sec
typedArray i/o 107169.4 Ops/sec
Script Preparation code:
AخA
 
function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}
var a = [...Array(10000)].map(_ => Math.random(1000000));
var ta = (new Float64Array(10000)).map(_ => Math.random(1000000));
Tests:
  • array slice

     
    a.slice(0);
  • typedArray slice

     
    ta.slice(0);
  • array i/o

     
    for (let i = 0; i < 10000; ++i) {
      a[i] = a[i] + 1;
    }
  • typedArray i/o

     
    for (let i = 0; i < 10000; ++i) {
      ta[i] = ta[i] + 1;
    }