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