lookup vs. includes

Benchmark created on


Setup

var list = ['foo', 'bar', 'baz', 'qux', 'foobar', 'barbar', 'bazbar', 'quxbar', 'foofoo', 'barfoo', 'bazfoo', 'quxfoo'];
var selections = list.slice(-3).concat(['not', 'in', 'list']);

Test runner

Ready to run.

Testing in
TestOps/sec
lookup
var lookup = list.reduce((acc, item) => {
    acc[item] = true;
    return acc;
}, {});
selections.map(item => lookup[item]);
ready
includes
selections.map(item => list.includes(item));
ready

Revisions

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