mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Fix _.template and _.flatten use in perf/perf.js.
This commit is contained in:
58
perf/perf.js
58
perf/perf.js
@@ -406,6 +406,10 @@
|
|||||||
\
|
\
|
||||||
var words = belt.keys(wordToNumber).slice(0, limit);\
|
var words = belt.keys(wordToNumber).slice(0, limit);\
|
||||||
}\
|
}\
|
||||||
|
if (typeof flatten != "undefined") {\
|
||||||
|
var _flattenDeep = _.flatten([[1]])[0] !== 1,\
|
||||||
|
lodashFlattenDeep = lodash.flatten([[1]]) !== 1;\
|
||||||
|
}\
|
||||||
if (typeof isEqual != "undefined") {\
|
if (typeof isEqual != "undefined") {\
|
||||||
var objectOfPrimitives = {\
|
var objectOfPrimitives = {\
|
||||||
"boolean": true,\
|
"boolean": true,\
|
||||||
@@ -498,10 +502,10 @@
|
|||||||
var settingsObject = { "variable": "data" };\
|
var settingsObject = { "variable": "data" };\
|
||||||
\
|
\
|
||||||
var _tpl = _.template(tpl),\
|
var _tpl = _.template(tpl),\
|
||||||
_tplVerbose = _.template(tplVerbose, null, settingsObject);\
|
_tplVerbose = _.template(tplVerbose, settingsObject);\
|
||||||
\
|
\
|
||||||
var lodashTpl = lodash.template(tpl),\
|
var lodashTpl = lodash.template(tpl),\
|
||||||
lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject);\
|
lodashTplVerbose = lodash.template(tplVerbose, settingsObject);\
|
||||||
}\
|
}\
|
||||||
if (typeof where != "undefined") {\
|
if (typeof where != "undefined") {\
|
||||||
var _findWhere = _.findWhere || _.find,\
|
var _findWhere = _.findWhere || _.find,\
|
||||||
@@ -1003,32 +1007,38 @@
|
|||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.flatten`')
|
Benchmark.Suite('`_.flatten`')
|
||||||
.add(buildName, '\
|
.add(buildName, {
|
||||||
lodash.flatten(nestedNumbers)'
|
'fn': 'lodash.flatten(nestedNumbers, !lodashFlattenDeep)',
|
||||||
)
|
'teardown': 'function flatten(){}'
|
||||||
.add(otherName, '\
|
})
|
||||||
_.flatten(nestedNumbers)'
|
.add(otherName, {
|
||||||
)
|
'fn': '_.flatten(nestedNumbers, !_flattenDeep)',
|
||||||
|
'teardown': 'function flatten(){}'
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.flatten` with objects')
|
Benchmark.Suite('`_.flatten` nested arrays of numbers with `isDeep`')
|
||||||
.add(buildName, '\
|
.add(buildName, {
|
||||||
lodash.flatten(nestedObjects)'
|
'fn': 'lodash.flatten(nestedNumbers, lodashFlattenDeep)',
|
||||||
)
|
'teardown': 'function flatten(){}'
|
||||||
.add(otherName, '\
|
})
|
||||||
_.flatten(nestedObjects)'
|
.add(otherName, {
|
||||||
)
|
'fn': '_.flatten(nestedNumbers, _flattenDeep)',
|
||||||
|
'teardown': 'function flatten(){}'
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.flatten` with `shallow`')
|
Benchmark.Suite('`_.flatten` nest arrays of objects with `isDeep`')
|
||||||
.add(buildName, '\
|
.add(buildName, {
|
||||||
lodash.flatten(nestedNumbers, true)'
|
'fn': 'lodash.flatten(nestedObjects, lodashFlattenDeep)',
|
||||||
)
|
'teardown': 'function flatten(){}'
|
||||||
.add(otherName, '\
|
})
|
||||||
_.flatten(nestedNumbers, true)'
|
.add(otherName, {
|
||||||
)
|
'fn': '_.flatten(nestedObjects, _flattenDeep)',
|
||||||
|
'teardown': 'function flatten(){}'
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -1808,11 +1818,11 @@
|
|||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.template` (slow path)')
|
Benchmark.Suite('`_.template` (slow path)')
|
||||||
.add(buildName, {
|
.add(buildName, {
|
||||||
'fn': 'lodash.template(tpl, tplData)',
|
'fn': 'lodash.template(tpl)(tplData)',
|
||||||
'teardown': 'function template(){}'
|
'teardown': 'function template(){}'
|
||||||
})
|
})
|
||||||
.add(otherName, {
|
.add(otherName, {
|
||||||
'fn': '_.template(tpl, tplData)',
|
'fn': '_.template(tpl)(tplData)',
|
||||||
'teardown': 'function template(){}'
|
'teardown': 'function template(){}'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user