Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object vs Map 5
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0
Browser:
Firefox 140
Operating system:
Linux
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
Map
72482.1 Ops/sec
Obj
46053.2 Ops/sec
Script Preparation code:
const rnd = () => Math.random().toString(36); const base = Array.from({length: 200}, () => [rnd(), rnd()]); const rndKey = () => base[Math.floor(Math.random() * base.length)][0]; const map = new Map(base); const obj = Object.setPrototypeOf(Object.fromEntries(base), null); const acc = []; function testMap() { const newKey = rnd(); map.set(newKey, rnd()); acc.push( map.get(rnd()), map.get(rndKey()) ); // doing actual work map.set(rndKey(), rnd()); map.delete(newKey); eval('acc.push("' + rnd() + '");'); // disable optimisations acc.length = 0; } function testObj() { const newKey = rnd(); obj[newKey] = rnd(); acc.push( obj[rnd()], obj[rndKey()] ) // doing actual work obj[rndKey()] = rnd(); delete obj[newKey]; eval('acc.push("' + rnd() + '");'); // disable optimisations acc.length = 0; // doing actual work }
Tests:
Map
testMap()
Obj
testObj()