lookup vs. includes (v2)

Revision 2 of this 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']);

var lookup = list.reduce((acc, item) => {
    acc[item] = item;
    return acc;
}, {});

Test runner

Ready to run.

Testing in
TestOps/sec
lookup
selections.map(item => item in lookup);
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.