mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Make _.bind follow ES5 spec so it will work with a common Backbone pattern. [closes #11]
Former-commit-id: 8d5e399ca9727a32604601f81fffd9134104c8f4
This commit is contained in:
53
perf/perf.js
53
perf/perf.js
@@ -55,6 +55,17 @@
|
||||
'seventeen', 'eighteen', 'nineteen', 'twenty'
|
||||
];
|
||||
|
||||
var ctor = function() { },
|
||||
func = function(greeting) { return greeting + ': ' + this.name; };
|
||||
|
||||
var lodashBoundNormal = lodash.bind(func, { 'name': 'moe' }),
|
||||
lodashBoundCtor = lodash.bind(ctor, { 'name': 'moe' }),
|
||||
lodashBoundPartial = lodash.bind(func, { 'name': 'moe' }, 'hi');
|
||||
|
||||
var _boundNormal = _.bind(func, { 'name': 'moe' }),
|
||||
_boundCtor = _.bind(ctor, { 'name': 'moe' }),
|
||||
_boundPartial = _.bind(func, { 'name': 'moe' }, 'hi');
|
||||
|
||||
for (var index = 0; index < 20; index++) {
|
||||
numbers[index] = index;
|
||||
object['key' + index] = index;
|
||||
@@ -108,6 +119,48 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('bind call')
|
||||
.add('Lo-Dash', function() {
|
||||
lodash.bind(func, { 'name': 'moe' }, 'hi');
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_.bind(func, { 'name': 'moe' }, 'hi');
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('bound normal')
|
||||
.add('Lo-Dash', function() {
|
||||
lodashBoundNormal();
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_boundNormal();
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('bound partial')
|
||||
.add('Lo-Dash', function() {
|
||||
lodashBoundPartial();
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_boundPartial();
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('bound constructor')
|
||||
.add('Lo-Dash', function() {
|
||||
new lodashBoundCtor();
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
new _boundCtor();
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('each array')
|
||||
.add('Lo-Dash', function() {
|
||||
|
||||
Reference in New Issue
Block a user