Add lazy chaining benchmark.

This commit is contained in:
John-David Dalton
2014-10-04 11:13:28 -07:00
parent 22cf82e44b
commit 6c3a17de71

View File

@@ -343,8 +343,12 @@
}\
}\
if (typeof chaining != "undefined") {\
var _chaining = _.chain ? _(numbers).chain() : _(numbers),\
lodashChaining = lodash(numbers);\
var odd = function(v) { return !!(v % 2); },\
square = function(v) { return v * v; };\
\
var largeArray = belt.range(10000),\
_chaining = _.chain ? _(largeArray).chain() : _(largeArray),\
lodashChaining = lodash(largeArray);\
}\
if (typeof compact != "undefined") {\
var uncompacted = numbers.slice();\
@@ -537,7 +541,7 @@
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_(...)` with a number')
Benchmark.Suite('`_(...)` with a number (edge case)')
.add(buildName, '\
lodash(2)'
)
@@ -566,20 +570,17 @@
)
);
// avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo
if (!isJava) {
suites.push(
Benchmark.Suite('`_(...).tap(...)`')
Benchmark.Suite('`_(...).map(...).filter(...).take(...).value()`')
.add(buildName, {
'fn': 'lodashChaining.tap(lodash.identity)',
'fn': 'lodashChaining.map(square).filter(odd).take(100).value()',
'teardown': 'function chaining(){}'
})
.add(otherName, {
'fn': '_chaining.tap(_.identity)',
'fn': '_chaining.map(square).filter(odd).take(100).value()',
'teardown': 'function chaining(){}'
})
);
}
/*--------------------------------------------------------------------------*/