Script Preparation code:
AخA
 
window.MAX_SIZE = 1000;
Tests:
  • Push item to an array

     
    const items = [];
    for (let i = 0; i < MAX_SIZE; i++) {
      items.push(i); 
    }
  • Append an item by spread

     
    let items = [];
    for (let i = 0; i < MAX_SIZE; i++) {
      items = [...items, i];
    }
  • Direct assign an item to an initialized array

     
    const items = new Array(MAX_SIZE);
    for (let i = 0; i < MAX_SIZE; i++) {
      items[i] = i; 
    }
  • Direct assign an item usign Array.from

     
    const items = Array.from(new Array(MAX_SIZE), (_, k) => k)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Push item to an array
    Append an item by spread
    Direct assign an item to an initialized array
    Direct assign an item usign Array.from

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0
Firefox 117 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Push item to an array 194618.2 Ops/sec
Append an item by spread 234.9 Ops/sec
Direct assign an item to an initialized array 281840.6 Ops/sec
Direct assign an item usign Array.from 78561.2 Ops/sec