set.has vs array.indexOf

Benchmark created on


Setup

let array = [...Array(1000)].map((x, i) => i)
let set = new Set(array)

Test runner

Ready to run.

Testing in
TestOps/sec
set.has
for (let i=0; i<10000000; i++) set.has(-1)
ready
array.indexOf
for (let i=0; i<10000000; i++) array.indexOf(-1)
ready

Revisions

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