Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Chrome 113
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
array sort 818.2 Ops/sec
typedArray sort 16052.4 Ops/sec
array i/o 953.1 Ops/sec
typedArray i/o 738.1 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 Float32Array(10000)).map(_ => Math.random(1000000));
Tests:
  • array sort

     
    a.sort();
  • typedArray sort

     
    ta.sort();
  • 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;
    }
    let tb = Array.from(ta);