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
Test name
Executions per second
array_1
265603824.0 Ops/sec
set_1
478463520.0 Ops/sec
array_2
210363296.0 Ops/sec
set_2
443106080.0 Ops/sec
array_4
151137344.0 Ops/sec
set_4
508071040.0 Ops/sec
array_8
110071272.0 Ops/sec
set_8
345779680.0 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)