mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Avoid enforcing strict mode in _.defaults, _.extend, and _.bindAll and add benchmarks for _.bindAll and _.functions. [closes #45]
Former-commit-id: 1bb0b5155d3ae46052b4a06cb538dff307e8ec5e
This commit is contained in:
59
perf/perf.js
59
perf/perf.js
@@ -82,12 +82,28 @@
|
||||
lodash = window.lodash;
|
||||
|
||||
var length = 20,
|
||||
funcNames = lodash.functions(lodash),
|
||||
numbers = [],
|
||||
object = {},
|
||||
fourNumbers = [5, 25, 10, 30],
|
||||
nestedNumbers = [1, [2], [3, [[4]]]],
|
||||
twoNumbers = [12, 21];
|
||||
|
||||
var bindAllObjects = [];
|
||||
|
||||
var objects = lodash.map(numbers, function(num) {
|
||||
return { 'num': num };
|
||||
});
|
||||
|
||||
lodash.times(this.count, function(index) {
|
||||
bindAllObjects[index] = lodash.clone(lodash);
|
||||
});
|
||||
|
||||
lodash.times(length, function(index) {
|
||||
numbers[index] = index;
|
||||
object['key' + index] = index;
|
||||
});
|
||||
|
||||
var ctor = function() { };
|
||||
|
||||
var func = function(greeting, punctuation) {
|
||||
@@ -219,15 +235,6 @@
|
||||
};
|
||||
|
||||
var words = _.keys(wordToNumber).slice(0, length);
|
||||
|
||||
for (var index = 0; index < length; index++) {
|
||||
numbers[index] = index;
|
||||
object['key' + index] = index;
|
||||
}
|
||||
|
||||
var objects = lodash.map(numbers, function(num) {
|
||||
return { 'num': num };
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -352,6 +359,28 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.bindAll` iterating arguments')
|
||||
.add('Lo-Dash', function() {
|
||||
lodash.bindAll.apply(lodash, [bindAllObjects.pop()].concat(funcNames));
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_.bindAll.apply(_, [bindAllObjects.pop()].concat(funcNames));
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.bindAll` iterating the `object`')
|
||||
.add('Lo-Dash', function() {
|
||||
lodash.bindAll(bindAllObjects.pop());
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_.bindAll(bindAllObjects.pop());
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.each` iterating an array')
|
||||
.add('Lo-Dash', function() {
|
||||
@@ -498,6 +527,18 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.functions`')
|
||||
.add('Lo-Dash', function() {
|
||||
lodash.functions(lodash);
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_.functions(lodash);
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.difference`')
|
||||
.add('Lo-Dash', function() {
|
||||
|
||||
Reference in New Issue
Block a user