test (v2)

Revision 2 of this benchmark created on


Preparation HTML

hello

Setup

const gIDs = Array.from({ length: 2000 }, (_, i) => `id-${i}`);
const gResources = gIDs.map((id) => ({ id }))

Test runner

Ready to run.

Testing in
TestOps/sec
hello
const byArray = (ids, resources) => {
  ids.forEach((id) => {
    const resource = resources.find((r) => r.id === id);
    console.log(resource);
  });  
}

byArray(gIDs, gResources)
ready
world
const byMap = (ids, resources) => {
  const resourcesMap = resources.reduce((prev, r) => {
    prev[r.id] = r;
    return prev;
  }, {});
  ids.forEach((id) => {
    const resource = resourcesMap[id];
     console.log(resource);
  });
}

byMap(gIDs, gResources)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.