Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
set includes vs array includes for two values
Check whether Set look ups are faster than Array includes even when there's only two values
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Set (second case)
100/s
Set (first case)
98/s
array (no case)
77/s
array (first case)
5/s
array (second case)
4/s
Set (no case)
3/s
View exact numbers
Test name
Executions per second
✓
Set (second case)
100 Ops/sec
Set (first case)
98 Ops/sec
array (no case)
77 Ops/sec
array (first case)
5 Ops/sec
array (second case)
4 Ops/sec
Set (no case)
3 Ops/sec
Script Preparation code:
var valueArray = [1, 2]; var valueSet = new Set([1, 2]);
Tests:
array (first case)
for (var i = 0; i < 1e7; ++i) { valueArray.includes(1); }
array (second case)
for (var i = 0; i < 1e7; ++i) { valueArray.includes(2); }
Set (first case)
for (var i = 0; i < 1e7; ++i) { valueSet.has(1); }
Set (second case)
for (var i = 0; i < 1e7; ++i) { valueSet.has(2); }
Set (no case)
for (var i = 0; i < 1e7; ++i) { valueArray.includes(3); }
array (no case)
for (var i = 0; i < 1e7; ++i) { valueSet.has(3); }