Script Preparation code:
x
 
var arr = [];
for (let i = 1; i <= 100; i++) {
  arr.push({ id: i, name: `${i}` });
}
var arr2 = [];
for (let i = 101; i <= 200; i++) {
  arr.push({ id: i, name: `${i}` });
}
var map = new Map(arr.map(item => [item.id, item]));
Tests:
  • new Map

     
    const map2 = new Map(arr2.map(item => [item.id, item]));
    map = new Map([...map, ...arr2.map(item => [item.id, item])]);
  • push array to map

     
    arr2.forEach(item => {
        map.set([item.id, item])
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    new Map
    push array to map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
new Map 129696.8 Ops/sec
push array to map 121318976.0 Ops/sec