Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Delete or not delete
Delete speed can be frustrating on V8 engine, but is it so in our case?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.3.1
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Use delete
61534.7 Ops/sec
Use undefined
66106.4 Ops/sec
Use filter and reduce
93245.2 Ops/sec
Tests:
Use delete
const content = '0'.repeat(53000); // ~53kb var cache = {}; let i = 100; // will give us ~5Mb while (i--) { const name = `item-${i}`; cache[name] = content; } // we will delete all 100 items function invalidateItem() { return true; } const invalidatedCache = (cache) => { const updatedCache = {}; Object.assign(updatedCache, cache); Object.keys(cache).filter(invalidateItem).forEach((name) => delete updatedCache[name]); return updatedCache; }; invalidatedCache(cache);
Use undefined
const content = '0'.repeat(53000); // ~53kb var cache = {}; let i = 100; // will give us ~5Mb while (i--) { const name = `item-${i}`; cache[name] = content; } // we will delete all 100 items function invalidateItem() { return true; } const invalidatedCache = (cache) => { const updatedCache = {}; Object.assign(updatedCache, cache); Object.keys(cache).filter(invalidateItem).forEach((name) => { updatedCache[name] = undefined; }); return updatedCache; }; invalidatedCache(cache);
Use filter and reduce
const content = '0'.repeat(53000); // ~53kb var cache = {}; let i = 100; // will give us ~5Mb while (i--) { const name = `item-${i}`; cache[name] = content; } // we will delete all 100 items function invalidateItem() { return true; } const invalidatedCache = (cache) => { const updatedCache = Object.keys(cache).filter(invalidateItem).reduce((cacheClone, key) => { cacheClone[key] = cache[key]; return cacheClone; }, Object.create(null)); return updatedCache; }; invalidatedCache(cache);