Lookup

Benchmark created on


Setup

let data = {
  meta: {
    a: 1234,
  },
  lookup: [],
  content: []
}

for(let i = 0;i<100000;i++) {
  let a = `123-${Date.now()}-${Math.random()}321`;
	if(i===5000) {
		a = 'macaroni';
	}
  data.lookup.push(a);
  data.content.push({
    name: a,
    content: Date.now()
  });
}

Teardown

data = {}

Test runner

Ready to run.

Testing in
TestOps/sec
with lookup
console.log(data.content[data.lookup.indexOf('macaroni')])
ready
without
console.log(data.content.find(el => el.name==='macaroni'))
ready

Revisions

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