mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Cleanup _.bind benchmarks and add chaining benchmarks. [ci skip]
Former-commit-id: 9198c34679709610a440f71856a3869eaa83090e
This commit is contained in:
49
perf/perf.js
49
perf/perf.js
@@ -224,18 +224,18 @@
|
||||
}\
|
||||
\
|
||||
if (typeof bind != "undefined") {\
|
||||
var contextObject = { "name": "moe" },\
|
||||
var thisArg = { "name": "moe" },\
|
||||
ctor = function() {};\
|
||||
\
|
||||
var func = function(greeting, punctuation) {\
|
||||
return greeting + ", " + this.name + (punctuation || ".");\
|
||||
};\
|
||||
\
|
||||
var lodashBoundNormal = lodash.bind(func, contextObject),\
|
||||
lodashBoundPartial = lodash.bind(func, contextObject, "hi");\
|
||||
var _boundNormal = _.bind(func, thisArg),\
|
||||
_boundPartial = _.bind(func, thisArg, "hi");\
|
||||
\
|
||||
var _boundNormal = _.bind(func, contextObject),\
|
||||
_boundPartial = _.bind(func, contextObject, "hi");\
|
||||
var lodashBoundNormal = lodash.bind(func, thisArg),\
|
||||
lodashBoundPartial = lodash.bind(func, thisArg, "hi");\
|
||||
}\
|
||||
\
|
||||
if (typeof bindAll != "undefined") {\
|
||||
@@ -250,6 +250,10 @@
|
||||
}, {});\
|
||||
}\
|
||||
}\
|
||||
if (typeof chaining != "undefined") {\
|
||||
var _chaining = _(numbers).chain(),\
|
||||
lodashChaining = lodash(numbers);\
|
||||
}\
|
||||
if (typeof compact != "undefined") {\
|
||||
var uncompacted = numbers.slice();\
|
||||
uncompacted[2] = false;\
|
||||
@@ -457,6 +461,40 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_(...)` with a number')
|
||||
.add(buildName, '\
|
||||
lodash(2)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_(2)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_(...)` with an object')
|
||||
.add(buildName, '\
|
||||
lodash(object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_(object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_(...).map(...)`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodashChaining.map(lodash.identity)',
|
||||
'teardown': 'function chaining(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_chaining.map(_.identity)',
|
||||
'teardown': 'function chaining(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)')
|
||||
.add(buildName, {
|
||||
@@ -1716,7 +1754,6 @@
|
||||
if (Benchmark.platform + '') {
|
||||
log(Benchmark.platform);
|
||||
}
|
||||
|
||||
// in the browser, expose `run` to be called later
|
||||
if (window.document && !window.phantom) {
|
||||
window.run = run;
|
||||
|
||||
Reference in New Issue
Block a user