Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set.has vs Array.includes for small number of items
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
array_1
171550800.0 Ops/sec
set_1
258738272.0 Ops/sec
array_2
153307184.0 Ops/sec
set_2
246484464.0 Ops/sec
array_4
134234400.0 Ops/sec
set_4
249682480.0 Ops/sec
array_8
101009456.0 Ops/sec
set_8
241585312.0 Ops/sec
Script Preparation code:
const item_1 = Math.floor(Math.random() * 1); const array_1 = new Array(1).map((_, i) => i); const set_1 = new Set(array_1); const item_2 = Math.floor(Math.random() * 2); const array_2 = new Array(2).map((_, i) => i); const set_2 = new Set(array_2); const item_4 = Math.floor(Math.random() * 4); const array_4 = new Array(4).map((_, i) => i); const set_4 = new Set(array_4); const item_8 = Math.floor(Math.random() * 8); const array_8 = new Array(8).map((_, i) => i); const set_8 = new Set(array_8);
Tests:
array_1
array_1.includes(item_1)
set_1
set_1.has(item_1)
array_2
array_2.includes(item_2)
set_2
set_2.has(item_2)
array_4
array_4.includes(item_4)
set_4
set_4.has(item_4)
array_8
array_8.includes(item_8)
set_8
set_8.has(item_8)