Created
October 11, 2016 12:58
-
-
Save xavicolomer/e530639748cb648bf6334812ab0bc73b to your computer and use it in GitHub Desktop.
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 characters
let realmItems = nextProps.items || [] | |
let start = new Date() | |
let finish = new Date() | |
let a = [] | |
// items.length = 479 | |
for (let i = 0, len = realmItems.length; i < len; ++i) { | |
// Option A | |
a.push({name: 'item_name' + Math.round(Math.random() * 100), category: {name: 'category_name ' + i, image: 'image_name'}}) | |
// Option B (accessing an object attribute) | |
// a.push({name: realmItems[i].name, category: {name: 'category_name ' + i, image: 'image_name'}}) | |
} | |
finish = new Date() | |
var dif = (finish.getTime() - start.getTime()) / (1000) | |
// Option A is 0.05 seconds | |
// Option B is ~4.66 seconds | |
console.log(dif, 'seconds') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment