Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Map vs Object vs Set lookup and add and lookup ugh
(version: 0)
Benchmark.js
Comparing performance of:
m vs o vs s
Created:
4 years ago
by:
Registered User
Go to the latest result
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); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
m
o
s
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Browser/OS:
Firefox 138 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
s
1K/s
m
1K/s
o
206/s
View exact numbers
Test name
Executions per second
✓
s
1,425 Ops/sec
m
1,356 Ops/sec
o
206 Ops/sec
Related benchmarks
Object keys vs Array map v2
array includes vs object key lookup, large arrays
Comments
Confirm delete:
Do you really want to delete benchmark?