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:
5 months ago
set_1
258.7M/s
set_4
249.7M/s
set_2
246.5M/s
set_8
241.6M/s
array_1
171.6M/s
array_2
153.3M/s
array_4
134.2M/s
array_8
101.0M/s
View exact numbers
Test name
Executions per second
✓
set_1
258,738,272 Ops/sec
set_4
249,682,480 Ops/sec
set_2
246,484,464 Ops/sec
set_8
241,585,312 Ops/sec
array_1
171,550,800 Ops/sec
array_2
153,307,184 Ops/sec
array_4
134,234,400 Ops/sec
array_8
101,009,456 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)