Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set vs Object vs Map vs array
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; rv:148.0) Gecko/20100101 Firefox/148.0
Browser:
Firefox 148
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Set
297018304.0 Ops/sec
Object
1629409408.0 Ops/sec
Map
30128262.0 Ops/sec
Array
15126.5 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);