Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set vs Object vs Map vs Array, Access
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/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Set
15559.7 Ops/sec
Object
21292.9 Ops/sec
Map
15232.0 Ops/sec
Array
26.2 Ops/sec
Script Preparation code:
var array = Array.from({length:10000},() => (()=>([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,a=>(a^Math.random()*16>>a/4).toString(16)))()) var set = new Set(array); var object = Object.fromEntries(array.map((k) => [k,true])) var map = new Map(array.map((k) => [k,true])); var randomAccess = [...array].sort(() => Math.random() -0.5).slice(0,1000)
Tests:
Set
for (const k of randomAccess) set.has(k)
Object
for (const k of randomAccess) object[k]
Map
for (const k of randomAccess) map.get(k)
Array
for (const k of randomAccess) array.includes(k)