arr vs obj

Benchmark created on


Setup

const size = 10000000
const arr = [...Array(size).keys()]

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

Test runner

Ready to run.

Testing in
TestOps/sec
arr include
const val1 = arr[567]

const val2 = arr[6677]

const val3 = arr[20004000]

ready
obj get
const val1 = obj[567]

const val2 = obj[6677]

const val3 = obj['qqqq']
ready

Revisions

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