Created
October 12, 2019 16:22
-
-
Save aburd/31c84f0a3db5e392e182c59d02c5ea1b to your computer and use it in GitHub Desktop.
Revisions
-
aburd created this gist
Oct 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ const testKeyName = 'foo' const testAmount = 100000000 const obj = { [testKeyName]: 'bar' } const map = new Map() map.set(testKeyName, 'bar') let objTestName = `Reading a property from obj ${testAmount} times` console.time(objTestName) for (let i = 0; i < testAmount; i++) { obj[testKeyName] } console.timeEnd(objTestName) let mapTestName = `Reading a property from map ${testAmount} times` console.time(mapTestName) for (let i = 0; i < testAmount; i++) { map.get(testKeyName) } console.timeEnd(mapTestName) objTestName = `Writing a property to obj ${testAmount} times` console.time(objTestName) for (let i = 0; i < testAmount; i++) { obj[testKeyName] = i } console.timeEnd(objTestName) mapTestName = `Writing a property to map ${testAmount} times` console.time(mapTestName) for (let i = 0; i < testAmount; i++) { map.set(testKeyName, i) } console.timeEnd(mapTestName)