Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map vs Object (3)
Lookup of map vs object
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
Map get
43.4 Ops/sec
Obj get
37.5 Ops/sec
Map set
31.4 Ops/sec
Obj set
30.1 Ops/sec
Map get after all
17.1 Ops/sec
Obj get after all
14.8 Ops/sec
Script Preparation code:
var map = new Map(); var obj = {}; var i = 0, count = 100000, a; function getKey(i) { return `i-${i}`; } // set default values for (i = 0; i < count; i++) { var key = getKey(i); var value = { i, key }; map.set(key, value); obj[key] = value; }
Tests:
Map get
for (i = 0; i < count; i++) { a = map.get(getKey(i)); }
Obj get
for (i = 0; i < count; i++) { a = obj[getKey(i)]; }
Map set
for (i = 0; i < count; i++) { var value = { i, key }; map.set(getKey(i + count), value); }
Obj set
for (i = 0; i < count; i++) { var value = { i, key }; obj[getKey(i + count)] = value; }
Map get after all
for (i = 0; i < count * 2; i++) { a = map.get(getKey(i)); }
Obj get after all
for (i = 0; i < count * 2; i++) { a = obj[getKey(i)]; }