mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Add _.matches benchmark.
This commit is contained in:
44
perf/perf.js
44
perf/perf.js
@@ -440,6 +440,15 @@
|
|||||||
numbers2[index] = index;\
|
numbers2[index] = index;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
if (typeof matches != "undefined") {\
|
||||||
|
var source = { "num": 9 };\
|
||||||
|
\
|
||||||
|
var _findWhere = _.findWhere || _.find,\
|
||||||
|
_match = _.matches && _.matches(source);\
|
||||||
|
\
|
||||||
|
var lodashFindWhere = lodash.findWhere || lodash.find,\
|
||||||
|
lodashMatch = lodash.matches && lodash.matches(source);\
|
||||||
|
}\
|
||||||
if (typeof multiArrays != "undefined") {\
|
if (typeof multiArrays != "undefined") {\
|
||||||
var twentyValues = belt.shuffle(belt.range(20)),\
|
var twentyValues = belt.shuffle(belt.range(20)),\
|
||||||
fortyValues = belt.shuffle(belt.range(40)),\
|
fortyValues = belt.shuffle(belt.range(40)),\
|
||||||
@@ -508,11 +517,6 @@
|
|||||||
var lodashTpl = lodash.template(tpl),\
|
var lodashTpl = lodash.template(tpl),\
|
||||||
lodashTplVerbose = lodash.template(tplVerbose, settingsObject);\
|
lodashTplVerbose = lodash.template(tplVerbose, settingsObject);\
|
||||||
}\
|
}\
|
||||||
if (typeof where != "undefined") {\
|
|
||||||
var _findWhere = _.findWhere || _.find,\
|
|
||||||
lodashFindWhere = lodash.findWhere || lodash.find,\
|
|
||||||
whereObject = { "num": 9 };\
|
|
||||||
}\
|
|
||||||
if (typeof wrap != "undefined") {\
|
if (typeof wrap != "undefined") {\
|
||||||
var add = function(a, b) {\
|
var add = function(a, b) {\
|
||||||
return a + b;\
|
return a + b;\
|
||||||
@@ -1004,12 +1008,12 @@
|
|||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.find` with `properties`')
|
Benchmark.Suite('`_.find` with `properties`')
|
||||||
.add(buildName, {
|
.add(buildName, {
|
||||||
'fn': 'lodashFindWhere(objects, whereObject)',
|
'fn': 'lodashFindWhere(objects, source)',
|
||||||
'teardown': 'function where(){}'
|
'teardown': 'function matches(){}'
|
||||||
})
|
})
|
||||||
.add(otherName, {
|
.add(otherName, {
|
||||||
'fn': '_findWhere(objects, whereObject)',
|
'fn': '_findWhere(objects, source)',
|
||||||
'teardown': 'function where(){}'
|
'teardown': 'function matches(){}'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1452,6 +1456,20 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
suites.push(
|
||||||
|
Benchmark.Suite('`_.matches` predicate')
|
||||||
|
.add(buildName, {
|
||||||
|
'fn': 'lodash.filter(objects, lodashMatch)',
|
||||||
|
'teardown': 'function matches(){}'
|
||||||
|
})
|
||||||
|
.add(otherName, {
|
||||||
|
'fn': '_.filter(objects, _match)',
|
||||||
|
'teardown': 'function matches(){}'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.max`')
|
Benchmark.Suite('`_.max`')
|
||||||
.add(buildName, '\
|
.add(buildName, '\
|
||||||
@@ -2037,12 +2055,12 @@
|
|||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.where`')
|
Benchmark.Suite('`_.where`')
|
||||||
.add(buildName, {
|
.add(buildName, {
|
||||||
'fn': 'lodash.where(objects, whereObject)',
|
'fn': 'lodash.where(objects, source)',
|
||||||
'teardown': 'function where(){}'
|
'teardown': 'function matches(){}'
|
||||||
})
|
})
|
||||||
.add(otherName, {
|
.add(otherName, {
|
||||||
'fn': '_.where(objects, whereObject)',
|
'fn': '_.where(objects, source)',
|
||||||
'teardown': 'function where(){}'
|
'teardown': 'function matches(){}'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user