mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add lazy chaining benchmark.
This commit is contained in:
19
perf/perf.js
19
perf/perf.js
@@ -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(){}'
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user