Array vs Object find

Benchmark created on


Setup

const mockArray = [...Array(10).keys()].map((_,i) => ({
  id: Math.random()
}));
const mockMap = mockArray.reduce((acc, item) => {
  return {
    ...acc,
    [item.id]: item
  };
}, {});

Test runner

Ready to run.

Testing in
TestOps/sec
Array
	mockArray.find(item => item.id === Math.random());
ready
Object

	mockMap[Math.random()];
ready

Revisions

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