Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
array.IndexOf vs new Set.has
array.indexOf vs new Set.has
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
withIndexOf
9474.0 Ops/sec
withSetHas
19.2 Ops/sec
Script Preparation code:
const arr = []; for (let i = 0; i < 1000000; ++i) { arr.push(i); } function withIndexOf(num) { return arr.indexOf(num) !== -1; } function withSetHas(num) { const set = new Set(arr); return set.has(num); }
Tests:
withIndexOf
withIndexOf(999999);
withSetHas
withSetHas(999999);