Cleanup _.bind benchmarks and add chaining benchmarks. [ci skip]

Former-commit-id: 9198c34679709610a440f71856a3869eaa83090e
This commit is contained in:
John-David Dalton
2013-03-03 23:58:07 -08:00
parent 87b1ac776f
commit 9f19c302d8

View File

@@ -224,18 +224,18 @@
}\ }\
\ \
if (typeof bind != "undefined") {\ if (typeof bind != "undefined") {\
var contextObject = { "name": "moe" },\ var thisArg = { "name": "moe" },\
ctor = function() {};\ ctor = function() {};\
\ \
var func = function(greeting, punctuation) {\ var func = function(greeting, punctuation) {\
return greeting + ", " + this.name + (punctuation || ".");\ return greeting + ", " + this.name + (punctuation || ".");\
};\ };\
\ \
var lodashBoundNormal = lodash.bind(func, contextObject),\ var _boundNormal = _.bind(func, thisArg),\
lodashBoundPartial = lodash.bind(func, contextObject, "hi");\ _boundPartial = _.bind(func, thisArg, "hi");\
\ \
var _boundNormal = _.bind(func, contextObject),\ var lodashBoundNormal = lodash.bind(func, thisArg),\
_boundPartial = _.bind(func, contextObject, "hi");\ lodashBoundPartial = lodash.bind(func, thisArg, "hi");\
}\ }\
\ \
if (typeof bindAll != "undefined") {\ if (typeof bindAll != "undefined") {\
@@ -250,6 +250,10 @@
}, {});\ }, {});\
}\ }\
}\ }\
if (typeof chaining != "undefined") {\
var _chaining = _(numbers).chain(),\
lodashChaining = lodash(numbers);\
}\
if (typeof compact != "undefined") {\ if (typeof compact != "undefined") {\
var uncompacted = numbers.slice();\ var uncompacted = numbers.slice();\
uncompacted[2] = false;\ 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( suites.push(
Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)') Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)')
.add(buildName, { .add(buildName, {
@@ -1716,7 +1754,6 @@
if (Benchmark.platform + '') { if (Benchmark.platform + '') {
log(Benchmark.platform); log(Benchmark.platform);
} }
// in the browser, expose `run` to be called later // in the browser, expose `run` to be called later
if (window.document && !window.phantom) { if (window.document && !window.phantom) {
window.run = run; window.run = run;