Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Member Access Object vs Map(string key) vs Map(object key)
(version: 49)
Member Access Object vs Map(string key) vs Map(object key)
Comparing performance of:
Object vs Map(string key) vs Map(object key)
Created:
5 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const N = 1<<16 let tmp; const getInt = (()=>{r=Math.random;f=Math.floor;return (a=0,b=0x100000000)=>f(r()*(b-a))+a})(); const getStr = ((n=8,a=0x20,b=0xD7B0)=>String.fromCharCode(...Array(n).fill(0,0,n).map(()=>getInt(a,b)))) const objS = {}; const mapS = new Map(); const mapO = new Map(); const strKeys = new Array(N); const objKeys = new Array(N); for(i=0;i<N;i++) { const strKey = getStr(); const objKey = { key : strKey }; const value = { num : getInt(), str : getStr(0x100)}; objS[strKey] = value; mapS.set(strKey, value); mapO.set(objKey, value); strKeys[i] = strKey; objKeys[i] = objKey; }
Tests:
Object
for(i=0;i<0x400;i++) tmp = objS[strKeys[getInt(0,N)]]
Map(string key)
for(i=0;i<0x400;i++) tmp = mapS.get(strKeys[getInt(0,N)])
Map(object key)
for(i=0;i<0x400;i++) tmp = mapO.get(objKeys[getInt(0,N)])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object
Map(string key)
Map(object key)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object
5529.3 Ops/sec
Map(string key)
4935.1 Ops/sec
Map(object key)
4917.4 Ops/sec
Related benchmarks:
Object vs Map
Map vs Object 12345
Object vs Map 5
contains misses: Map vs Set vs Array vs Symbol vs UID
indexOf vs map.get vs obj[key]
test Map vs Object with string which use string as key and value
Map vs Object with 100 keys
Map vs Object with 100 keys and mutate
Map vs Object with 100 keys and 1/2 delete
Comments
Confirm delete:
Do you really want to delete benchmark?