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