Script Preparation code:
AخA
 
function randstr(N) {
  return (Math.random().toString(36)+'00000000000000000').slice(2, N+2);
}
var dataset = [];
for (var x = 0; x < 100000; x++) {
  dataset.push({id: 'xx' + x, name: randstr(10), other: randstr(10)});
}
var indexedDataset = {};
for (var item of dataset) {
  indexedDataset[item.id] = item;
}
var indexMap = {};
for (var [i, item] of dataset.entries()) {
  indexMap[item.id] = i;
}
function assertEq(a, b) {
  if (a !== b) {
    new Error(`Failed assert: "${a}" expected "${b}"`);
  }
}
Tests:
  • Array.find

     
    for (var x = 0; x < 10000; ++x) {
      const item = dataset.find(v => v.id == 'xx' + 123);
      assertEq(item.id, 'xx' + 123);
    }
  • indexed copy

     
    for (var x = 0; x < 10000; ++x) {
      const item = indexedDataset['xx' + 123];
      assertEq(item.id, 'xx' + 123);
    }
  • index map

     
    for (var x = 0; x < 10000; ++x) {
      const item = dataset[indexMap['xx' + 123]];
      assertEq(item.id, 'xx' + 123);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.find
    indexed copy
    index map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36
Chrome 53 on Linux
View result in a separate tab
Test name Executions per second
Array.find 42.2 Ops/sec
indexed copy 351.6 Ops/sec
index map 261.1 Ops/sec