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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0
Browser:
Chrome 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
set_8
59.7M/s
set_4
59.6M/s
set_1
58.6M/s
set_2
58.4M/s
array_1
49.5M/s
array_4
44.4M/s
array_2
44.3M/s
array_8
38.4M/s
View exact numbers
Test name
Executions per second
✓
set_8
59,723,020 Ops/sec
set_4
59,612,848 Ops/sec
set_1
58,616,264 Ops/sec
set_2
58,414,468 Ops/sec
array_1
49,544,920 Ops/sec
array_4
44,401,620 Ops/sec
array_2
44,347,332 Ops/sec
array_8
38,383,360 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)