Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map vs Object vs Set lookup and add and lookup ugh
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
m
1355.8 Ops/sec
o
206.1 Ops/sec
s
1425.2 Ops/sec
Script Preparation code:
var map = new Map(); var obj = {}; var set = new Set(); var ary = []; var ary2 = []; for (let i=0; i<10000; i++) { ary.push(Math.random()); ary2.push(Math.random()); }
Tests:
m
for (let a of ary) { if (!map.has(a)) map.set(a, true); } for (let a of ary) { const x = map.has(a); } for (let a of ary2) { const x = map.has(a); }
o
for (let a of ary) { if (obj[a] === undefined) obj[a] = true; } for (let a of ary) { const x = !!obj[a]; } for (let a of ary2) { const x = !!obj[a]; }
s
for (let a of ary) { if (!set.has(a)) set.add(a); } for (let a of ary) { const x = set.has(a); } for (let a of ary2) { const x = set.has(a); }