Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set vs Object vs Map vs Array (Iteration)
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Windows
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Set
18723.1 Ops/sec
Object
5439.7 Ops/sec
Map
16148.5 Ops/sec
Array
54223.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
let sum = 0; set.forEach((v) => { sum += v; });
Object
let sum = 0; for(const k in object){ const v = object[k] sum += v; }
Map
let sum = 0; map.forEach((v) => { sum += v; });
Array
let sum = 0; array.forEach((v) => { sum += v; });