Script Preparation code:
x
 
let arr = [];
for (let i = 0; i < 100000; i++)
    arr.push(i % 256);
var u8a = new Uint8Array(arr);
Tests:
  • Uint8Array index

     
    const a = u8a; //(u8a as unknown) as number[];
    const al = a.length;
    let s = 0;
    for(let i=0; i<al; i++)
      s += a[i];
     
  • Array.from array index

     
    const a = Array.from(u8a);
    const al = a.length;
    let s = 0;
    for(let i=0; i<al; i++)
      s += a[i];
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Uint8Array index
    Array.from array index

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Chrome 93 on Linux
View result in a separate tab
Test name Executions per second
Uint8Array index 6802.5 Ops/sec
Array.from array index 214.5 Ops/sec