Add _.compact, _.defaults, and _.extend benchmarks.

Former-commit-id: adebc01aeda08323174af63166c2b6e0e798c313
This commit is contained in:
John-David Dalton
2012-10-23 09:09:14 -07:00
parent 71fe13b249
commit b0361183df

View File

@@ -224,6 +224,12 @@
}, {});\
}\
}\
if (typeof compact != "undefined") {\
var uncompacted = numbers.slice();\
uncompacted[2] = false;\
uncompacted[6] = null;\
uncompacted[18] = "";\
}\
\
if (typeof countBy != "undefined" || typeof omit != "undefined") {\
var wordToNumber = {\
@@ -537,6 +543,20 @@
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.compact`')
.add(buildName, {
'fn': 'lodash.compact(uncompacted)',
'teardown': 'function compact(){}'
})
.add(otherName, {
'fn': '_.compact(uncompacted)',
'teardown': 'function compact(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.contains` iterating an array')
.add(buildName, '\
@@ -595,6 +615,18 @@
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.defaults`')
.add(buildName, '\
lodash.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'
)
.add(otherName, '\
_.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'
)
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.difference`')
.add(buildName, '\
@@ -723,6 +755,18 @@
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.extend`')
.add(buildName, '\
lodash.extend({}, object)'
)
.add(otherName, '\
_.extend({}, object)'
)
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.filter` iterating an array')
.add(buildName, '\