Script Preparation code:
AخA
 
var arr = Array.from({length: 1000000}).map((_,i) => ({id: i}));
var arrMap =  new Map(arr.entries());
function idGen() {
  return Math.floor(Math.random() * 1000000) % 1000000
}
Tests:
  • array to map and find many

     
    const arrToMap = new Map(arr.entries());
    const id = idGen()
    arrToMap.get(id)
  • array find

     
    const id = idGen()
    arr.find((item) => item.id ==id)
  • map find

     
    const id = idGen()
    arrMap.get(id)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    array to map and find many
    array find
    map find

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Chrome 107 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
array to map and find many 6.0 Ops/sec
array find 155.0 Ops/sec
map find 1338361.9 Ops/sec