Skip to content

Instantly share code, notes, and snippets.

@xavicolomer
Created October 11, 2016 12:58
Show Gist options
  • Save xavicolomer/e530639748cb648bf6334812ab0bc73b to your computer and use it in GitHub Desktop.
Save xavicolomer/e530639748cb648bf6334812ab0bc73b to your computer and use it in GitHub Desktop.
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