arr vs obj (v2)

Revision 2 of this benchmark created on


Setup

const size = 1000000
const arr = [...Array(size).keys()].reverse()

const obj = Object.fromEntries(arr.map((val) => [[val], [1]]))

Test runner

Ready to run.

Testing in
TestOps/sec
arr include
const val1 = arr.includes(567)

const val2 = arr.includes(66077)

const val3 = arr.includes(2000000)

ready
obj get
const val1 = obj[567]

const val2 = obj[66077]

const val3 = obj['qqqq']
ready

Revisions

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