Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Get object from map in Map, Object and map in WeakMap
(version: 1)
Comparing performance of:
Object vs Map vs Map in WeakMap vs Object in WeakMap
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let o, m, w, owm; const map = new Map(); const obj = Object.create(null); const wm = new WeakMap(); const wm2 = new WeakMap(); const objSet = (ob, k, v)=>{ ob[k] = v; return ob; }; let data = Object.create(null); wm.set(data, new Map()); wm2.set(data, Object.create(null)); for (let i = 65; i < 90; i++) { let t = String.fromCharCode(i); obj[t] = i; map.set(t, i); wm.set(data, (wm.get(data)).set(t, i)); wm2.set(data, objSet(wm2.get(data), t, i)); }
Tests:
Object
o = obj['M'];
Map
m = map.get('M');
Map in WeakMap
w = wm.get(data).get('M');
Object in WeakMap
owm = wm2.get(data)['M'];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Object
Map
Map in WeakMap
Object in WeakMap
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object
8553419.0 Ops/sec
Map
8156600.0 Ops/sec
Map in WeakMap
7180517.0 Ops/sec
Object in WeakMap
7575181.0 Ops/sec
Related benchmarks:
WeakMap vs Symbol Property
Array vs Object vs Map vs WeakMap access3
WeakMap vs arrays read performance !!
WeakMap vs Symbol Property v2
luke test
WeakMap vs Symbol Property vs String Property
WeakMap vs Symbol Property 900
Array vs Object vs Map vs WeakMap access (123123)
Map v Object v Set v Array ALL base actions
Comments
Confirm delete:
Do you really want to delete benchmark?