Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set has vs object key vs array include
performance comparison of ways to find if an array contains a value
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/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Includes
1332641.1 Ops/sec
Object[key]
14625378.0 Ops/sec
Set.has
15797105.0 Ops/sec
map.has
15849242.0 Ops/sec
key in obj
14158992.0 Ops/sec
Script Preparation code:
var obj = (new Array(1000)).fill(null).reduce((prev, newVal) => {prev[Math.random() + ''] = Math.random() + ''; return prev; }, { sausage: 'tst' }); var map = new Map(Object.entries(obj)) var array = Object.keys(obj); var set = new Set(array);
Tests:
Includes
array.includes('sausage') array.includes('notFound')
Object[key]
obj['sausage'] obj['notFound']
Set.has
set.has('sausage') set.has('notFound')
map.has
map.has('sausage') map.has('notFound')
key in obj
'sausage' in obj; 'notFound' in obj;