Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map.entries() vs. Map.forEach() vs. Map.keys() + Map.get()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Browser:
Chrome 149
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 days ago
Test name
Executions per second
entries()
3420180.5 Ops/sec
forEach()
2633109.5 Ops/sec
keys() + get()
2525575.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
// Bereite eine globale Test-Map mit 50 Einträgen vor const LIST_CACHE = new Map(); for (let i = 0; i < 50; i++) { const itemMock = { id: `item_${i}`, maxStack: 99, isUnique: false }; LIST_CACHE.set(itemMock, Math.floor(Math.random() * 10) + 1); } // Minimaler Mock für die #has Methode des Inventars (gibt immer true zurück, um reinen Schleifen-Overhead zu messen) const inventoryMock = { has: function(item, count) { // Simuliere minimale Logik, damit der JIT die Schleife nicht wegoptimiert return item.maxStack > 0 && count > 0; } };
Tests:
entries()
let allItemsMatch = true; for (const [item, count] of LIST_CACHE) { if (!inventoryMock.has(item, count)) { allItemsMatch = false; break; } }
forEach()
let allItemsMatch = true; LIST_CACHE.forEach((count, item) => { if (!allItemsMatch) return; if (!inventoryMock.has(item, count)) { allItemsMatch = false; } });
keys() + get()
let allItemsMatch = true; for (const item of LIST_CACHE.keys()) { if (!inventoryMock.has(item, LIST_CACHE.get(item))) { allItemsMatch = false; break; } }