Map vs Object (R+W)
Read/Write of Map vs Object (competition use only, please don't use these in the real world).
Date tested:
3 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:86.0) Gecko/20100101 Firefox/86.0
Test name
Executions per second
Map
218.9 Ops/sec
Object
217.1 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var map = new Map(); var obj = {}; var count = 10000; var i = 0, a;
Tests:
Map
for (i = 0; i < count; i++) { map.set((i * 10000).toString(), i); } for (i = 0; i < count; i++) { a = map.get((i * 10000).toString()); }
Object
for (i = 0; i < count; i++) { obj[(i * 10000).toString()] = i; } for (i = 0; i < count; i++) { a = obj[(i * 10000).toString()]; }
Open this result on MeasureThat.net