Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
fixed 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 (iPhone; CPU iPhone OS 18_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.2.1
Device Platform:
Mobile
Date tested:
one year ago
set_4
508.1M/s
set_1
478.5M/s
set_2
443.1M/s
set_8
345.8M/s
array_1
265.6M/s
array_2
210.4M/s
array_4
151.1M/s
array_8
110.1M/s
View exact numbers
Test name
Executions per second
✓
set_4
508,071,040 Ops/sec
set_1
478,463,520 Ops/sec
set_2
443,106,080 Ops/sec
set_8
345,779,680 Ops/sec
array_1
265,603,824 Ops/sec
array_2
210,363,296 Ops/sec
array_4
151,137,344 Ops/sec
array_8
110,071,272 Ops/sec
Script Preparation code:
const item_1 = Math.floor(Math.random() * 1); const array_1 = new Array(1).fill(0).map((_, i) => i); const set_1 = new Set(array_1); const item_2 = Math.floor(Math.random() * 2); const array_2 = new Array(2).fill(0).map((_, i) => i); const set_2 = new Set(array_2); const item_4 = Math.floor(Math.random() * 4); const array_4 = new Array(4).fill(0).map((_, i) => i); const set_4 = new Set(array_4); const item_8 = Math.floor(Math.random() * 8); const array_8 = new Array(8).fill(0).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)