Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set vs Object vs Map vs array but with strings
Compare the speed to retrieve a value from three data structures that can be used for boolean referencing; i.e. for mapping enabled settings.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Set
234187712.0 Ops/sec
Object
177250592.0 Ops/sec
Map
228874096.0 Ops/sec
Array
51862.7 Ops/sec
Script Preparation code:
const array = Array.from({ length: 10000 }, (_, idx) => `${idx}`); const set = new Set(array); const object = Object.fromEntries(array.map((x) => [`${x}`, true])); const map = new Map(Object.entries(object));
Tests:
Set
set.has('0'); set.has('42'); set.has('69'); set.has('9999'); set.has('520'); set.has('1314'); set.has('168'); set.has('19'); set.has('4'); set.has('10000');
Object
'0' in object; '42' in object; '69' in object; '9999' in object; '520' in object; '1314' in object; '168' in object; '19' in object; '4' in object; '10000' in object;
Map
map.has('0'); map.has('42'); map.has('69'); map.has('9999'); map.has('520'); map.has('1314'); map.has('168'); map.has('19'); map.has('4'); map.has('10000');
Array
array.includes('0'); array.includes('42'); array.includes('69'); array.includes('9999'); array.includes('520'); array.includes('1314'); array.includes('168'); array.includes('19'); array.includes('4'); array.includes('10000');