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 (fixed)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 11; Mobile; rv:136.0) Gecko/136.0 Firefox/136.0
Browser:
Firefox Mobile 136
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
set_1
535.9M/s
set_2
535.0M/s
set_8
533.2M/s
set_4
530.5M/s
array_1
20.4M/s
array_2
20.0M/s
array_4
19.3M/s
array_8
18.6M/s
View exact numbers
Test name
Executions per second
✓
set_1
535,945,088 Ops/sec
set_2
535,038,176 Ops/sec
set_8
533,195,424 Ops/sec
set_4
530,497,504 Ops/sec
array_1
20,402,522 Ops/sec
array_2
20,027,638 Ops/sec
array_4
19,272,594 Ops/sec
array_8
18,608,556 Ops/sec
Script Preparation code:
const item_1 = Math.floor(1 / 2); const array_1 = new Array(1).fill(0).map((_, i) => i); const set_1 = new Set(array_1); const item_2 = Math.floor(2 / 2); const array_2 = new Array(2).fill(0).map((_, i) => i); const set_2 = new Set(array_2); const item_4 = Math.floor(4 / 2); const array_4 = new Array(4).fill(0).map((_, i) => i); const set_4 = new Set(array_4); const item_8 = Math.floor(8 / 2); 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)