Skip to content

Instantly share code, notes, and snippets.

@letmein
Last active September 9, 2016 10:40
Show Gist options
  • Save letmein/18ee7a1b368177746704b18615b971e8 to your computer and use it in GitHub Desktop.
Save letmein/18ee7a1b368177746704b18615b971e8 to your computer and use it in GitHub Desktop.
profile a function in console
measure = function (subj) {
var t0 = performance.now()
subj()
var t1 = performance.now()
return (t1 - t0) + 'ms'
}
arr = _.times(10000, function (i) { return { id: i, name: 'Foo ' + i } })
index = _.keyBy(arr, 'id')
arr2 = _.times(5000, function (i) { return { id: i + 1, name: 'Foo ' + i +1 } })
measure(function () {
index2 = _.keyBy(arr2, 'id')
_.chain(index).clone().merge(index2).value()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment