Last active
September 9, 2016 10:40
-
-
Save letmein/18ee7a1b368177746704b18615b971e8 to your computer and use it in GitHub Desktop.
profile a function in console
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
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