diff --git a/perf/index.html b/perf/index.html
index b53f458a8..e66844734 100644
--- a/perf/index.html
+++ b/perf/index.html
@@ -36,7 +36,7 @@
// is the applet really needed?
while (!(measured = new Date - begin)) { }
- if (measured != 1 && !((perfNow = window.performance) && typeof (perfNow.webkitNow || perfNow.now) == 'function')) {
+ if (measured != 1 && !((perfNow = window.performance) && typeof (perfNow.now || perfNow.webkitNow) == 'function')) {
// load applet
document.write('');
}
diff --git a/perf/perf.js b/perf/perf.js
index b30f776e8..3b8534830 100644
--- a/perf/perf.js
+++ b/perf/perf.js
@@ -63,7 +63,7 @@
* @param {String} text The text to log.
*/
function log(text) {
- console.log(text);
+ console.log(text + '');
if (fbPanel) {
// scroll the Firebug Lite panel down
fbPanel.scrollTop = fbPanel.scrollHeight;
@@ -86,253 +86,12 @@
/*--------------------------------------------------------------------------*/
- lodash.extend(Benchmark.options, {
- 'async': true,
- 'setup': function() {
- var window = Function('return this || global')(),
- _ = window._,
- lodash = window.lodash,
- belt = this.name == 'Lo-Dash' ? lodash : _;
-
- var index,
- limit = 20,
- object = {},
- objects = Array(limit),
- numbers = Array(limit),
- fourNumbers = [5, 25, 10, 30],
- nestedNumbers = [1, [2], [3, [[4]]]],
- twoNumbers = [12, 21];
-
- for (index = 0; index < limit; index++) {
- numbers[index] = index;
- object['key' + index] = index;
- objects[index] = { 'num': index };
- }
-
- if (typeof bind != 'undefined') {
- var contextObject = { 'name': 'moe' },
- ctor = function() {};
-
- var func = function(greeting, punctuation) {
- return greeting + ', ' + this.name + (punctuation || '.');
- };
-
- var lodashBoundNormal = lodash.bind(func, contextObject),
- lodashBoundCtor = lodash.bind(ctor, contextObject),
- lodashBoundPartial = lodash.bind(func, contextObject, 'hi');
-
- var _boundNormal = _.bind(func, contextObject),
- _boundCtor = _.bind(ctor, contextObject),
- _boundPartial = _.bind(func, contextObject, 'hi');
- }
-
- if (typeof bindAll != 'undefined') {
- var bindAllObjects = Array(this.count),
- funcNames = belt.functions(lodash);
-
- // potentially expensive
- for (index = 0; index < this.count; index++) {
- bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {
- object[funcName] = lodash[funcName];
- return object;
- }, {});
- }
- }
-
- if (typeof countBy != 'undefined') {
- var wordToNumber = {
- 'one': 1,
- 'two': 2,
- 'three': 3,
- 'four': 4,
- 'five': 5,
- 'six': 6,
- 'seven': 7,
- 'eight': 8,
- 'nine': 9,
- 'ten': 10,
- 'eleven': 11,
- 'twelve': 12,
- 'thirteen': 13,
- 'fourteen': 14,
- 'fifteen': 15,
- 'sixteen': 16,
- 'seventeen': 17,
- 'eighteen': 18,
- 'nineteen': 19,
- 'twenty': 20,
- 'twenty-one': 21,
- 'twenty-two': 22,
- 'twenty-three': 23,
- 'twenty-four': 24,
- 'twenty-five': 25
- };
-
- var words = belt.keys(wordToNumber).slice(0, limit);
- }
-
- if (typeof isEqual != 'undefined') {
- var objectOfPrimitives = {
- 'boolean': true,
- 'number': 1,
- 'string': 'a'
- };
-
- var objectOfObjects = {
- 'boolean': new Boolean(true),
- 'number': new Number(1),
- 'string': new String('a')
- };
-
- var object2 = {},
- objects2 = Array(limit),
- numbers2 = Array(limit),
- nestedNumbers2 = [1, [2], [3, [[4]]]];
-
- for (index = 0; index < limit; index++) {
- numbers2[index] = index;
- object2['key' + index] = index;
- objects2[index] = { 'num': index };
- }
- }
-
- if (typeof multiArrays != 'undefined') {
- var twentyFiveValues = Array(25),
- twentyFiveValues2 = Array(25),
- fiftyValues = Array(50),
- fiftyValues2 = Array(50),
- seventyFiveValues = Array(75),
- seventyFiveValues2 = Array(75),
- lowerChars = 'abcdefghijklmnopqrstuvwxyz'.split(''),
- upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
-
- for (index = 0; index < 75; index++) {
- if (index < 26) {
- if (index < 20) {
- twentyFiveValues[index] = lowerChars[index];
- twentyFiveValues2[index] = upperChars[index];
- }
- else if (index < 25) {
- twentyFiveValues[index] =
- twentyFiveValues2[index] = index;
- }
- fiftyValues[index] =
- seventyFiveValues[index] = lowerChars[index];
-
- fiftyValues2[index] =
- seventyFiveValues2[index] = upperChars[index];
- }
- else {
- if (index < 50) {
- fiftyValues[index] = index;
- fiftyValues2[index] = index + (index < 40 ? 75 : 0);
- }
- seventyFiveValues[index] = index;
- seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);
- }
- }
- }
-
- if (typeof template != 'undefined') {
- var tplData = {
- 'header1': 'Header1',
- 'header2': 'Header2',
- 'header3': 'Header3',
- 'header4': 'Header4',
- 'header5': 'Header5',
- 'header6': 'Header6',
- 'list': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
- };
-
- var tplBase =
- '
' +
- "" +
- "" +
- "" +
- "" +
- "" +
- "";
-
- var tpl =
- tplBase +
- "
" +
- "- <%= list[0] %>
" +
- "- <%= list[1] %>
" +
- "- <%= list[2] %>
" +
- "- <%= list[3] %>
" +
- "- <%= list[4] %>
" +
- "- <%= list[5] %>
" +
- "- <%= list[6] %>
" +
- "- <%= list[7] %>
" +
- "- <%= list[8] %>
" +
- "- <%= list[9] %>
" +
- '
' +
- '
';
-
- var tplWithEvaluate =
- tplBase +
- "" +
- '<% for (var index = 0, length = list.length; index < length; index++) { %>' +
- "- <%= list[index] %>
" +
- '<% } %>' +
- '
' +
- '';
-
- var tplBaseVerbose =
- '' +
- "" +
- "" +
- "" +
- "" +
- "" +
- "";
-
- var tplVerbose =
- tplBaseVerbose +
- "
" +
- "- <%= data.list[0] %>
" +
- "- <%= data.list[1] %>
" +
- "- <%= data.list[2] %>
" +
- "- <%= data.list[3] %>
" +
- "- <%= data.list[4] %>
" +
- "- <%= data.list[5] %>
" +
- "- <%= data.list[6] %>
" +
- "- <%= data.list[7] %>
" +
- "- <%= data.list[8] %>
" +
- "- <%= data.list[9] %>
" +
- '
' +
- '
';
-
- var tplVerboseWithEvaluate =
- tplBaseVerbose +
- "" +
- '<% for (var index = 0, length = data.list.length; index < length; index++) { %>' +
- "- <%= data.list[index] %>
" +
- '<% } %>' +
- '
' +
- '';
-
- var settingsObject = { 'variable': 'data' };
-
- var lodashTpl = lodash.template(tpl),
- lodashTplWithEvaluate = lodash.template(tplWithEvaluate),
- lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject),
- lodashTplVerboseWithEvaluate = lodash.template(tplVerboseWithEvaluate, null, settingsObject);
-
- var _tpl = _.template(tpl),
- _tplWithEvaluate = _.template(tplWithEvaluate),
- _tplVerbose = _.template(tplVerbose, null, settingsObject),
- _tplVerboseWithEvaluate = _.template(tplVerboseWithEvaluate, null, settingsObject);
- }
- }
- });
-
lodash.extend(Benchmark.Suite.options, {
'onStart': function() {
log('\n' + this.name + ':');
},
'onCycle': function(event) {
- log(event.target + '');
+ log(event.target);
},
'onComplete': function() {
var formatNumber = Benchmark.formatNumber,
@@ -386,18 +145,256 @@
/*--------------------------------------------------------------------------*/
+ lodash.extend(Benchmark.options, {
+ 'async': true,
+ 'setup': '\
+ var window = Function("return this || global")(),\
+ _ = window._,\
+ lodash = window.lodash,\
+ belt = this.name == "Lo-Dash" ? lodash : _;\
+ \
+ var index,\
+ limit = 20,\
+ object = {},\
+ objects = Array(limit),\
+ numbers = Array(limit),\
+ fourNumbers = [5, 25, 10, 30],\
+ nestedNumbers = [1, [2], [3, [[4]]]],\
+ twoNumbers = [12, 21];\
+ \
+ for (index = 0; index < limit; index++) {\
+ numbers[index] = index;\
+ object["key" + index] = index;\
+ objects[index] = { "num": index };\
+ }\
+ \
+ if (typeof bind != "undefined") {\
+ var contextObject = { "name": "moe" },\
+ ctor = function() {};\
+ \
+ var func = function(greeting, punctuation) {\
+ return greeting + ", " + this.name + (punctuation || ".");\
+ };\
+ \
+ var lodashBoundNormal = lodash.bind(func, contextObject),\
+ lodashBoundCtor = lodash.bind(ctor, contextObject),\
+ lodashBoundPartial = lodash.bind(func, contextObject, "hi");\
+ \
+ var _boundNormal = _.bind(func, contextObject),\
+ _boundCtor = _.bind(ctor, contextObject),\
+ _boundPartial = _.bind(func, contextObject, "hi");\
+ }\
+ \
+ if (typeof bindAll != "undefined") {\
+ var bindAllObjects = Array(this.count),\
+ funcNames = belt.functions(lodash);\
+ \
+ // potentially expensive\n\
+ for (index = 0; index < this.count; index++) {\
+ bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\
+ object[funcName] = lodash[funcName];\
+ return object;\
+ }, {});\
+ }\
+ }\
+ \
+ if (typeof countBy != "undefined") {\
+ var wordToNumber = {\
+ "one": 1,\
+ "two": 2,\
+ "three": 3,\
+ "four": 4,\
+ "five": 5,\
+ "six": 6,\
+ "seven": 7,\
+ "eight": 8,\
+ "nine": 9,\
+ "ten": 10,\
+ "eleven": 11,\
+ "twelve": 12,\
+ "thirteen": 13,\
+ "fourteen": 14,\
+ "fifteen": 15,\
+ "sixteen": 16,\
+ "seventeen": 17,\
+ "eighteen": 18,\
+ "nineteen": 19,\
+ "twenty": 20,\
+ "twenty-one": 21,\
+ "twenty-two": 22,\
+ "twenty-three": 23,\
+ "twenty-four": 24,\
+ "twenty-five": 25\
+ };\
+ \
+ var words = belt.keys(wordToNumber).slice(0, limit);\
+ }\
+ \
+ if (typeof isEqual != "undefined") {\
+ var objectOfPrimitives = {\
+ "boolean": true,\
+ "number": 1,\
+ "string": "a"\
+ };\
+ \
+ var objectOfObjects = {\
+ "boolean": new Boolean(true),\
+ "number": new Number(1),\
+ "string": new String("a")\
+ };\
+ \
+ var object2 = {},\
+ objects2 = Array(limit),\
+ numbers2 = Array(limit),\
+ nestedNumbers2 = [1, [2], [3, [[4]]]];\
+ \
+ for (index = 0; index < limit; index++) {\
+ numbers2[index] = index;\
+ object2["key" + index] = index;\
+ objects2[index] = { "num": index };\
+ }\
+ }\
+ \
+ if (typeof multiArrays != "undefined") {\
+ var twentyFiveValues = Array(25),\
+ twentyFiveValues2 = Array(25),\
+ fiftyValues = Array(50),\
+ fiftyValues2 = Array(50),\
+ seventyFiveValues = Array(75),\
+ seventyFiveValues2 = Array(75),\
+ lowerChars = "abcdefghijklmnopqrstuvwxyz".split(""),\
+ upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");\
+ \
+ for (index = 0; index < 75; index++) {\
+ if (index < 26) {\
+ if (index < 20) {\
+ twentyFiveValues[index] = lowerChars[index];\
+ twentyFiveValues2[index] = upperChars[index];\
+ }\
+ else if (index < 25) {\
+ twentyFiveValues[index] =\
+ twentyFiveValues2[index] = index;\
+ }\
+ fiftyValues[index] =\
+ seventyFiveValues[index] = lowerChars[index];\
+ \
+ fiftyValues2[index] =\
+ seventyFiveValues2[index] = upperChars[index];\
+ }\
+ else {\
+ if (index < 50) {\
+ fiftyValues[index] = index;\
+ fiftyValues2[index] = index + (index < 40 ? 75 : 0);\
+ }\
+ seventyFiveValues[index] = index;\
+ seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);\
+ }\
+ }\
+ }\
+ \
+ if (typeof template != "undefined") {\
+ var tplData = {\
+ "header1": "Header1",\
+ "header2": "Header2",\
+ "header3": "Header3",\
+ "header4": "Header4",\
+ "header5": "Header5",\
+ "header6": "Header6",\
+ "list": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]\
+ };\
+ \
+ var tplBase =\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "";\
+ \
+ var tpl =\
+ tplBase +\
+ "
" +\
+ "- <%= list[0] %>
" +\
+ "- <%= list[1] %>
" +\
+ "- <%= list[2] %>
" +\
+ "- <%= list[3] %>
" +\
+ "- <%= list[4] %>
" +\
+ "- <%= list[5] %>
" +\
+ "- <%= list[6] %>
" +\
+ "- <%= list[7] %>
" +\
+ "- <%= list[8] %>
" +\
+ "- <%= list[9] %>
" +\
+ "
" +\
+ "
";\
+ \
+ var tplWithEvaluate =\
+ tplBase +\
+ "" +\
+ "<% for (var index = 0, length = list.length; index < length; index++) { %>" +\
+ "- <%= list[index] %>
" +\
+ "<% } %>" +\
+ "
" +\
+ "";\
+ \
+ var tplBaseVerbose =\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "" +\
+ "";\
+ \
+ var tplVerbose =\
+ tplBaseVerbose +\
+ "
" +\
+ "- <%= data.list[0] %>
" +\
+ "- <%= data.list[1] %>
" +\
+ "- <%= data.list[2] %>
" +\
+ "- <%= data.list[3] %>
" +\
+ "- <%= data.list[4] %>
" +\
+ "- <%= data.list[5] %>
" +\
+ "- <%= data.list[6] %>
" +\
+ "- <%= data.list[7] %>
" +\
+ "- <%= data.list[8] %>
" +\
+ "- <%= data.list[9] %>
" +\
+ "
" +\
+ "
";\
+ \
+ var tplVerboseWithEvaluate =\
+ tplBaseVerbose +\
+ "" +\
+ "<% for (var index = 0, length = data.list.length; index < length; index++) { %>" +\
+ "- <%= data.list[index] %>
" +\
+ "<% } %>" +\
+ "
" +\
+ "";\
+ \
+ var settingsObject = { "variable": "data" };\
+ \
+ var lodashTpl = lodash.template(tpl),\
+ lodashTplWithEvaluate = lodash.template(tplWithEvaluate),\
+ lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject),\
+ lodashTplVerboseWithEvaluate = lodash.template(tplVerboseWithEvaluate, null, settingsObject);\
+ \
+ var _tpl = _.template(tpl),\
+ _tplWithEvaluate = _.template(tplWithEvaluate),\
+ _tplVerbose = _.template(tplVerbose, null, settingsObject),\
+ _tplVerboseWithEvaluate = _.template(tplVerboseWithEvaluate, null, settingsObject);\
+ }'
+ });
+
+ /*--------------------------------------------------------------------------*/
+
suites.push(
Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.bind(func, { 'name': 'moe' }, 'hi');
- },
+ 'fn': 'lodash.bind(func, { "name": "moe" }, "hi")',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.bind(func, { 'name': 'moe' }, 'hi');
- },
+ 'fn': '_.bind(func, { "name": "moe" }, "hi")',
'teardown': 'function bind(){}'
})
);
@@ -405,15 +402,11 @@
suites.push(
Benchmark.Suite('bound call')
.add('Lo-Dash', {
- 'fn': function() {
- lodashBoundNormal();
- },
+ 'fn': 'lodashBoundNormal()',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- _boundNormal();
- },
+ 'fn': '_boundNormal()',
'teardown': 'function bind(){}'
})
);
@@ -421,15 +414,11 @@
suites.push(
Benchmark.Suite('bound call with arguments')
.add('Lo-Dash', {
- 'fn': function() {
- lodashBoundNormal('hi', '!');
- },
+ 'fn': 'lodashBoundNormal("hi", "!")',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- _boundNormal('hi', '!');
- },
+ 'fn': '_boundNormal("hi", "!")',
'teardown': 'function bind(){}'
})
);
@@ -437,15 +426,11 @@
suites.push(
Benchmark.Suite('bound and partially applied call (uses native `Function#bind` if available)')
.add('Lo-Dash', {
- 'fn': function() {
- lodashBoundPartial();
- },
+ 'fn': 'lodashBoundPartial()',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- _boundPartial();
- },
+ 'fn': '_boundPartial()',
'teardown': 'function bind(){}'
})
);
@@ -453,15 +438,11 @@
suites.push(
Benchmark.Suite('bound and partially applied call with arguments (uses native `Function#bind` if available)')
.add('Lo-Dash', {
- 'fn': function() {
- lodashBoundPartial('!');
- },
+ 'fn': 'lodashBoundPartial("!")',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- _boundPartial('!');
- },
+ 'fn': '_boundPartial("!")',
'teardown': 'function bind(){}'
})
);
@@ -469,15 +450,11 @@
suites.push(
Benchmark.Suite('bound and called in a `new` expression, i.e. `new bound` (edge case)')
.add('Lo-Dash', {
- 'fn': function() {
- new lodashBoundCtor();
- },
+ 'fn': 'new lodashBoundCtor()',
'teardown': 'function bind(){}'
})
.add('Underscore', {
- 'fn': function() {
- new _boundCtor();
- },
+ 'fn': 'new _boundCtor()',
'teardown': 'function bind(){}'
})
);
@@ -487,15 +464,11 @@
suites.push(
Benchmark.Suite('`_.bindAll` iterating arguments')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.bindAll.apply(lodash, [bindAllObjects.pop()].concat(funcNames));
- },
+ 'fn': 'lodash.bindAll.apply(lodash, [bindAllObjects.pop()].concat(funcNames))',
'teardown': 'function bindAll(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.bindAll.apply(_, [bindAllObjects.pop()].concat(funcNames));
- },
+ 'fn': '_.bindAll.apply(_, [bindAllObjects.pop()].concat(funcNames))',
'teardown': 'function bindAll(){}'
})
);
@@ -503,15 +476,11 @@
suites.push(
Benchmark.Suite('`_.bindAll` iterating the `object`')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.bindAll(bindAllObjects.pop());
- },
+ 'fn': 'lodash.bindAll(bindAllObjects.pop())',
'teardown': 'function bindAll(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.bindAll(bindAllObjects.pop());
- },
+ 'fn': '_.bindAll(bindAllObjects.pop())',
'teardown': 'function bindAll(){}'
})
);
@@ -520,38 +489,34 @@
suites.push(
Benchmark.Suite('`_.clone` with an object')
- .add('Lo-Dash', function() {
- lodash.clone(object);
- })
- .add('Underscore', function() {
- _.clone(object);
- })
+ .add('Lo-Dash', '\
+ lodash.clone(object)'
+ )
+ .add('Underscore', '\
+ _.clone(object)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.countBy` with `callback` iterating an array')
- .add('Lo-Dash', function() {
- lodash.countBy(numbers, function(num) { return num >> 1; });
- })
- .add('Underscore', function() {
- _.countBy(numbers, function(num) { return num >> 1; });
- })
+ .add('Lo-Dash', '\
+ lodash.countBy(numbers, function(num) { return num >> 1; })'
+ )
+ .add('Underscore', '\
+ _.countBy(numbers, function(num) { return num >> 1; })'
+ )
);
suites.push(
Benchmark.Suite('`_.countBy` with `property` name iterating an array')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.countBy(words, 'length');
- },
+ 'fn': 'lodash.countBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.countBy(words, 'length');
- },
+ 'fn': '_.countBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
@@ -559,15 +524,11 @@
suites.push(
Benchmark.Suite('`_.countBy` with `callback` iterating an object')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.countBy(wordToNumber, function(num) { return num >> 1; });
- },
+ 'fn': 'lodash.countBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.countBy(wordToNumber, function(num) { return num >> 1; });
- },
+ 'fn': '_.countBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
);
@@ -576,26 +537,22 @@
suites.push(
Benchmark.Suite('`_.difference`')
- .add('Lo-Dash', function() {
- lodash.difference(numbers, fourNumbers, twoNumbers);
- })
- .add('Underscore', function() {
- _.difference(numbers, fourNumbers, twoNumbers);
- })
+ .add('Lo-Dash', '\
+ lodash.difference(numbers, fourNumbers, twoNumbers)'
+ )
+ .add('Underscore', '\
+ _.difference(numbers, fourNumbers, twoNumbers)'
+ )
);
suites.push(
Benchmark.Suite('`_.difference` iterating 25 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.difference(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': 'lodash.difference(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.difference(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': '_.difference(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -603,15 +560,11 @@
suites.push(
Benchmark.Suite('`_.difference` iterating 50 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.difference(fiftyValues, fiftyValues2);
- },
+ 'fn': 'lodash.difference(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.difference(fiftyValues, fiftyValues2);
- },
+ 'fn': '_.difference(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -619,15 +572,11 @@
suites.push(
Benchmark.Suite('`_.difference` iterating 75 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.difference(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': 'lodash.difference(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.difference(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': '_.difference(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -636,184 +585,180 @@
suites.push(
Benchmark.Suite('`_.each` iterating an array')
- .add('Lo-Dash', function() {
- var result = [];
- lodash.each(numbers, function(num) {
- result.push(num * 2);
- });
- })
- .add('Underscore', function() {
- var result = [];
- _.each(numbers, function(num) {
- result.push(num * 2);
- });
- })
+ .add('Lo-Dash', '\
+ var result = [];\
+ lodash.each(numbers, function(num) {\
+ result.push(num * 2);\
+ })'
+ )
+ .add('Underscore', '\
+ var result = [];\
+ _.each(numbers, function(num) {\
+ result.push(num * 2);\
+ })'
+ )
);
suites.push(
Benchmark.Suite('`_.each` iterating an array with `thisArg` (slow path)')
- .add('Lo-Dash', function() {
- var result = [];
- lodash.each(numbers, function(num, index) {
- result.push(num + this['key' + index]);
- }, object);
- })
- .add('Underscore', function() {
- var result = [];
- _.each(numbers, function(num, index) {
- result.push(num + this['key' + index]);
- }, object);
- })
+ .add('Lo-Dash', '\
+ var result = [];\
+ lodash.each(numbers, function(num, index) {\
+ result.push(num + this["key" + index]);\
+ }, object)'
+ )
+ .add('Underscore', '\
+ var result = [];\
+ _.each(numbers, function(num, index) {\
+ result.push(num + this["key" + index]);\
+ }, object)'
+ )
);
suites.push(
Benchmark.Suite('`_.each` iterating an object')
- .add('Lo-Dash', function() {
- var result = [];
- lodash.each(object, function(num) {
- result.push(num * 2);
- });
- })
- .add('Underscore', function() {
- var result = [];
- _.each(object, function(num) {
- result.push(num * 2);
- });
- })
+ .add('Lo-Dash', '\
+ var result = [];\
+ lodash.each(object, function(num) {\
+ result.push(num * 2);\
+ })'
+ )
+ .add('Underscore', '\
+ var result = [];\
+ _.each(object, function(num) {\
+ result.push(num * 2);\
+ })'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.filter` iterating an array')
- .add('Lo-Dash', function() {
- lodash.filter(numbers, function(num) {
- return num % 2;
- });
- })
- .add('Underscore', function() {
- _.filter(numbers, function(num) {
- return num % 2;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.filter(numbers, function(num) {\
+ return num % 2;\
+ })'
+ )
+ .add('Underscore', '\
+ _.filter(numbers, function(num) {\
+ return num % 2;\
+ })'
+ )
);
suites.push(
Benchmark.Suite('`_.filter` iterating an array with `thisArg` (slow path)')
- .add('Lo-Dash', function() {
- lodash.filter(numbers, function(num, index) {
- return this['key' + index] % 2;
- }, object);
- })
- .add('Underscore', function() {
- _.filter(numbers, function(num, index) {
- return this['key' + index] % 2;
- }, object);
- })
+ .add('Lo-Dash', '\
+ lodash.filter(numbers, function(num, index) {\
+ return this["key" + index] % 2;\
+ }, object)'
+ )
+ .add('Underscore', '\
+ _.filter(numbers, function(num, index) {\
+ return this["key" + index] % 2;\
+ }, object)'
+ )
);
suites.push(
Benchmark.Suite('`_.filter` iterating an object')
- .add('Lo-Dash', function() {
- lodash.filter(object, function(num) {
- return num % 2;
- });
- })
- .add('Underscore', function() {
- _.filter(object, function(num) {
- return num % 2;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.filter(object, function(num) {\
+ return num % 2\
+ })'
+ )
+ .add('Underscore', '\
+ _.filter(object, function(num) {\
+ return num % 2\
+ })'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.find` iterating an array')
- .add('Lo-Dash', function() {
- lodash.find(numbers, function(num) {
- return num === 19;
- });
- })
- .add('Underscore', function() {
- _.find(numbers, function(num) {
- return num === 19;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.find(numbers, function(num) {\
+ return num === 19;\
+ })'
+ )
+ .add('Underscore', '\
+ _.find(numbers, function(num) {\
+ return num === 19;\
+ })'
+ )
);
suites.push(
Benchmark.Suite('`_.find` iterating an object')
- .add('Lo-Dash', function() {
- lodash.find(object, function(value, key) {
- return /\D9$/.test(key);
- });
- })
- .add('Underscore', function() {
- _.find(object, function(value, key) {
- return /\D9$/.test(key);
- });
- })
+ .add('Lo-Dash', '\
+ lodash.find(object, function(value, key) {\
+ return /\D9$/.test(key);\
+ })'
+ )
+ .add('Underscore', '\
+ _.find(object, function(value, key) {\
+ return /\D9$/.test(key);\
+ })'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.flatten`')
- .add('Lo-Dash', function() {
- lodash.flatten(nestedNumbers);
- })
- .add('Underscore', function() {
- _.flatten(nestedNumbers);
- })
+ .add('Lo-Dash', '\
+ lodash.flatten(nestedNumbers)'
+ )
+ .add('Underscore', '\
+ _.flatten(nestedNumbers)'
+ )
);
suites.push(
Benchmark.Suite('`_.flatten` with `shallow`')
- .add('Lo-Dash', function() {
- lodash.flatten(nestedNumbers, true);
- })
- .add('Underscore', function() {
- _.flatten(nestedNumbers, true);
- })
+ .add('Lo-Dash', '\
+ lodash.flatten(nestedNumbers, true)'
+ )
+ .add('Underscore', '\
+ _.flatten(nestedNumbers, true)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.functions`')
- .add('Lo-Dash', function() {
- lodash.functions(lodash);
- })
- .add('Underscore', function() {
- _.functions(lodash);
- })
+ .add('Lo-Dash', '\
+ lodash.functions(lodash)'
+ )
+ .add('Underscore', '\
+ _.functions(lodash)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.groupBy` with `callback` iterating an array')
- .add('Lo-Dash', function() {
- lodash.groupBy(numbers, function(num) { return num >> 1; });
- })
- .add('Underscore', function() {
- _.groupBy(numbers, function(num) { return num >> 1; });
- })
+ .add('Lo-Dash', '\
+ lodash.groupBy(numbers, function(num) { return num >> 1; })'
+ )
+ .add('Underscore', '\
+ _.groupBy(numbers, function(num) { return num >> 1; })'
+ )
);
suites.push(
Benchmark.Suite('`_.groupBy` with `property` name iterating an array')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.groupBy(words, 'length');
- },
+ 'fn': 'lodash.groupBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.groupBy(words, 'length');
- },
+ 'fn': '_.groupBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
@@ -821,15 +766,11 @@
suites.push(
Benchmark.Suite('`_.groupBy` with `callback` iterating an object')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.groupBy(wordToNumber, function(num) { return num >> 1; });
- },
+ 'fn': 'lodash.groupBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.groupBy(wordToNumber, function(num) { return num >> 1; });
- },
+ 'fn': '_.groupBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
);
@@ -838,48 +779,44 @@
suites.push(
Benchmark.Suite('`_.indexOf`')
- .add('Lo-Dash', function() {
- lodash.indexOf(numbers, 9);
- })
- .add('Underscore', function() {
- _.indexOf(numbers, 9);
- })
+ .add('Lo-Dash', '\
+ lodash.indexOf(numbers, 9)'
+ )
+ .add('Underscore', '\
+ _.indexOf(numbers, 9)'
+ )
);
suites.push(
Benchmark.Suite('`_.indexOf` with `isSorted`')
- .add('Lo-Dash', function() {
- lodash.indexOf(numbers, 19, true);
- })
- .add('Underscore', function() {
- _.indexOf(numbers, 19, true);
- })
+ .add('Lo-Dash', '\
+ lodash.indexOf(numbers, 19, true)'
+ )
+ .add('Underscore', '\
+ _.indexOf(numbers, 19, true)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.intersection`')
- .add('Lo-Dash', function() {
- lodash.intersection(numbers, fourNumbers, twoNumbers);
- })
- .add('Underscore', function() {
- _.intersection(numbers, fourNumbers, twoNumbers);
- })
+ .add('Lo-Dash', '\
+ lodash.intersection(numbers, fourNumbers, twoNumbers)'
+ )
+ .add('Underscore', '\
+ _.intersection(numbers, fourNumbers, twoNumbers)'
+ )
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 25 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.intersection(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': 'lodash.intersection(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.intersection(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': '_.intersection(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -887,15 +824,11 @@
suites.push(
Benchmark.Suite('`_.intersection` iterating 50 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.intersection(fiftyValues, fiftyValues2);
- },
+ 'fn': 'lodash.intersection(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.intersection(fiftyValues, fiftyValues2);
- },
+ 'fn': '_.intersection(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -903,15 +836,11 @@
suites.push(
Benchmark.Suite('`_.intersection` iterating 75 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.intersection(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': 'lodash.intersection(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.intersection(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': '_.intersection(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -920,32 +849,32 @@
suites.push(
Benchmark.Suite('`_.invoke` iterating an array')
- .add('Lo-Dash', function() {
- lodash.invoke(numbers, 'toFixed', '2');
- })
- .add('Underscore', function() {
- _.invoke(numbers, 'toFixed', '2');
- })
+ .add('Lo-Dash', '\
+ lodash.invoke(numbers, "toFixed", "2")'
+ )
+ .add('Underscore', '\
+ _.invoke(numbers, "toFixed", "2")'
+ )
);
suites.push(
Benchmark.Suite('`_.invoke` with a function for `methodName` iterating an array')
- .add('Lo-Dash', function() {
- lodash.invoke(numbers, String.prototype.split, '');
- })
- .add('Underscore', function() {
- _.invoke(numbers, String.prototype.split, '');
- })
+ .add('Lo-Dash', '\
+ lodash.invoke(numbers, String.prototype.split, "")'
+ )
+ .add('Underscore', '\
+ _.invoke(numbers, String.prototype.split, "")'
+ )
);
suites.push(
Benchmark.Suite('`_.invoke` iterating an object')
- .add('Lo-Dash', function() {
- lodash.invoke(object, 'toFixed', '2');
- })
- .add('Underscore', function() {
- _.invoke(object, 'toFixed', '2');
- })
+ .add('Lo-Dash', '\
+ lodash.invoke(object, "toFixed", "2")'
+ )
+ .add('Underscore', '\
+ _.invoke(object, "toFixed", "2")'
+ )
);
/*--------------------------------------------------------------------------*/
@@ -953,15 +882,11 @@
suites.push(
Benchmark.Suite('`_.isEqual` comparing primitives and objects (edge case)')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.isEqual(objectOfPrimitives, objectOfObjects);
- },
+ 'fn': 'lodash.isEqual(objectOfPrimitives, objectOfObjects)',
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.isEqual(objectOfPrimitives, objectOfObjects);
- },
+ 'fn': '_.isEqual(objectOfPrimitives, objectOfObjects)',
'teardown': 'function isEqual(){}'
})
);
@@ -969,15 +894,11 @@
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.isEqual(numbers, numbers2);
- },
+ 'fn': 'lodash.isEqual(numbers, numbers2)',
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.isEqual(numbers, numbers2);
- },
+ 'fn': '_.isEqual(numbers, numbers2)',
'teardown': 'function isEqual(){}'
})
);
@@ -985,15 +906,11 @@
suites.push(
Benchmark.Suite('`_.isEqual` comparing nested arrays')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.isEqual(nestedNumbers, nestedNumbers2);
- },
+ 'fn': 'lodash.isEqual(nestedNumbers, nestedNumbers2)',
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.isEqual(nestedNumbers, nestedNumbers2);
- },
+ 'fn': '_.isEqual(nestedNumbers, nestedNumbers2)',
'teardown': 'function isEqual(){}'
})
);
@@ -1001,15 +918,11 @@
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays of objects')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.isEqual(objects, objects2);
- },
+ 'fn': 'lodash.isEqual(objects, objects2)',
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.isEqual(objects, objects2);
- },
+ 'fn': '_.isEqual(objects, objects2)',
'teardown': 'function isEqual(){}'
})
);
@@ -1017,15 +930,11 @@
suites.push(
Benchmark.Suite('`_.isEqual` comparing objects')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.isEqual(object, object2);
- },
+ 'fn': 'lodash.isEqual(object, object2)',
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.isEqual(object, object2);
- },
+ 'fn': '_.isEqual(object, object2)',
'teardown': 'function isEqual(){}'
})
);
@@ -1034,176 +943,172 @@
suites.push(
Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)')
- .add('Lo-Dash', function() {
- lodash.keys(object);
- })
- .add('Underscore', function() {
- _.keys(object);
- })
+ .add('Lo-Dash', '\
+ lodash.keys(object)'
+ )
+ .add('Underscore', '\
+ _.keys(object)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.lastIndexOf`')
- .add('Lo-Dash', function() {
- lodash.lastIndexOf(numbers, 9);
- })
- .add('Underscore', function() {
- _.lastIndexOf(numbers, 9);
- })
+ .add('Lo-Dash', '\
+ lodash.lastIndexOf(numbers, 9)'
+ )
+ .add('Underscore', '\
+ _.lastIndexOf(numbers, 9)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.map` iterating an array')
- .add('Lo-Dash', function() {
- lodash.map(objects, function(value) {
- return value.num;
- });
- })
- .add('Underscore', function() {
- _.map(objects, function(value) {
- return value.num;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.map(objects, function(value) {\
+ return value.num;\
+ })'
+ )
+ .add('Underscore', '\
+ _.map(objects, function(value) {\
+ return value.num;\
+ })'
+ )
);
suites.push(
Benchmark.Suite('`_.map` with `thisArg` iterating an array (slow path)')
- .add('Lo-Dash', function() {
- lodash.map(objects, function(value, index) {
- return this['key' + index] + value.num;
- }, object);
- })
- .add('Underscore', function() {
- _.map(objects, function(value, index) {
- return this['key' + index] + value.num;
- }, object);
- })
+ .add('Lo-Dash', '\
+ lodash.map(objects, function(value, index) {\
+ return this["key" + index] + value.num;\
+ }, object)'
+ )
+ .add('Underscore', '\
+ _.map(objects, function(value, index) {\
+ return this["key" + index] + value.num;\
+ }, object)'
+ )
);
suites.push(
Benchmark.Suite('`_.map` iterating an object')
- .add('Lo-Dash', function() {
- lodash.map(object, function(value) {
- return value;
- });
- })
- .add('Underscore', function() {
- _.map(object, function(value) {
- return value;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.map(object, function(value) {\
+ return value;\
+ })'
+ )
+ .add('Underscore', '\
+ _.map(object, function(value) {\
+ return value;\
+ })'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.max`')
- .add('Lo-Dash', function() {
- lodash.max(numbers);
- })
- .add('Underscore', function() {
- _.max(numbers);
- })
+ .add('Lo-Dash', '\
+ lodash.max(numbers)'
+ )
+ .add('Underscore', '\
+ _.max(numbers)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.min`')
- .add('Lo-Dash', function() {
- lodash.min(numbers);
- })
- .add('Underscore', function() {
- _.min(numbers);
- })
+ .add('Lo-Dash', '\
+ lodash.min(numbers)'
+ )
+ .add('Underscore', '\
+ _.min(numbers)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.pick`')
- .add('Lo-Dash', function() {
- lodash.pick(object, 'key6', 'key13');
- })
- .add('Underscore', function() {
- _.pick(object, 'key6', 'key13');
- })
+ .add('Lo-Dash', '\
+ lodash.pick(object, "key6", "key13")'
+ )
+ .add('Underscore', '\
+ _.pick(object, "key6", "key13")'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.pluck`')
- .add('Lo-Dash', function() {
- lodash.pluck(objects, 'num');
- })
- .add('Underscore', function() {
- _.pluck(objects, 'num');
- })
+ .add('Lo-Dash', '\
+ lodash.pluck(objects, "num")'
+ )
+ .add('Underscore', '\
+ _.pluck(objects, "num")'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.shuffle`')
- .add('Lo-Dash', function() {
- lodash.shuffle(numbers);
- })
- .add('Underscore', function() {
- _.shuffle(numbers);
- })
+ .add('Lo-Dash', '\
+ lodash.shuffle(numbers)'
+ )
+ .add('Underscore', '\
+ _.shuffle(numbers)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.size` with an object')
- .add('Lo-Dash', function() {
- lodash.size(object);
- })
- .add('Underscore', function() {
- _.size(object);
- })
+ .add('Lo-Dash', '\
+ lodash.size(object)'
+ )
+ .add('Underscore', '\
+ _.size(object)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.sortBy` with `callback`')
- .add('Lo-Dash', function() {
- lodash.sortBy(numbers, function(num) { return Math.sin(num); });
- })
- .add('Underscore', function() {
- _.sortBy(numbers, function(num) { return Math.sin(num); });
- })
+ .add('Lo-Dash', '\
+ lodash.sortBy(numbers, function(num) { return Math.sin(num); })'
+ )
+ .add('Underscore', '\
+ _.sortBy(numbers, function(num) { return Math.sin(num); })'
+ )
);
suites.push(
Benchmark.Suite('`_.sortBy` with `callback` and `thisArg` (slow path)')
- .add('Lo-Dash', function() {
- lodash.sortBy(numbers, function(num) { return this.sin(num); }, Math);
- })
- .add('Underscore', function() {
- _.sortBy(numbers, function(num) { return this.sin(num); }, Math);
- })
+ .add('Lo-Dash', '\
+ lodash.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
+ )
+ .add('Underscore', '\
+ _.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
+ )
);
suites.push(
Benchmark.Suite('`_.sortBy` with `property` name')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.sortBy(words, 'length');
- },
+ 'fn': 'lodash.sortBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.sortBy(words, 'length');
- },
+ 'fn': '_.sortBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
@@ -1212,30 +1117,28 @@
suites.push(
Benchmark.Suite('`_.sortedIndex`')
- .add('Lo-Dash', function() {
- lodash.sortedIndex(numbers, 25);
- })
- .add('Underscore', function() {
- _.sortedIndex(numbers, 25);
- })
+ .add('Lo-Dash', '\
+ lodash.sortedIndex(numbers, 25)'
+ )
+ .add('Underscore', '\
+ _.sortedIndex(numbers, 25)'
+ )
);
suites.push(
Benchmark.Suite('`_.sortedIndex` with `callback`')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.sortedIndex(words, 'twenty-five', function(value) {
- return wordToNumber[value];
- });
- },
+ 'fn': '\
+ lodash.sortedIndex(words, "twenty-five", function(value) {\
+ return wordToNumber[value];\
+ })',
'teardown': 'function countBy(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.sortedIndex(words, 'twenty-five', function(value) {
- return wordToNumber[value];
- });
- },
+ 'fn': '\
+ _.sortedIndex(words, "twenty-five", function(value) {\
+ return wordToNumber[value];\
+ })',
'teardown': 'function countBy(){}'
})
);
@@ -1245,15 +1148,11 @@
suites.push(
Benchmark.Suite('`_.template` without "evaluate" delimiters (slow path)')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.template(tpl, tplData);
- },
+ 'fn': 'lodash.template(tpl, tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.template(tpl, tplData);
- },
+ 'fn': '_.template(tpl, tplData)',
'teardown': 'function template(){}'
})
);
@@ -1261,15 +1160,11 @@
suites.push(
Benchmark.Suite('`_.template` with "evaluate" delimiters (slow path)')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.template(tplWithEvaluate, tplData);
- },
+ 'fn': 'lodash.template(tplWithEvaluate, tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.template(tplWithEvaluate, tplData);
- },
+ 'fn': '_.template(tplWithEvaluate, tplData)',
'teardown': 'function template(){}'
})
);
@@ -1277,15 +1172,11 @@
suites.push(
Benchmark.Suite('compiled template without "evaluate" delimiters')
.add('Lo-Dash', {
- 'fn': function() {
- lodashTpl(tplData);
- },
+ 'fn': 'lodashTpl(tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _tpl(tplData);
- },
+ 'fn': '_tpl(tplData)',
'teardown': 'function template(){}'
})
);
@@ -1293,15 +1184,11 @@
suites.push(
Benchmark.Suite('compiled template with "evaluate" delimiters')
.add('Lo-Dash', {
- 'fn': function() {
- lodashTplWithEvaluate(tplData);
- },
+ 'fn': 'lodashTplWithEvaluate(tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _tplWithEvaluate(tplData);
- },
+ 'fn': '_tplWithEvaluate(tplData)',
'teardown': 'function template(){}'
})
);
@@ -1309,15 +1196,11 @@
suites.push(
Benchmark.Suite('compiled template without a with-statement or "evaluate" delimiters')
.add('Lo-Dash', {
- 'fn': function() {
- lodashTplVerbose(tplData);
- },
+ 'fn': 'lodashTplVerbose(tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _tplVerbose(tplData);
- },
+ 'fn': '_tplVerbose(tplData)',
'teardown': 'function template(){}'
})
);
@@ -1325,15 +1208,11 @@
suites.push(
Benchmark.Suite('compiled template without a with-statement using "evaluate" delimiters')
.add('Lo-Dash', {
- 'fn': function() {
- lodashTplVerboseWithEvaluate(tplData);
- },
+ 'fn': 'lodashTplVerboseWithEvaluate(tplData)',
'teardown': 'function template(){}'
})
.add('Underscore', {
- 'fn': function() {
- _tplVerboseWithEvaluate(tplData);
- },
+ 'fn': '_tplVerboseWithEvaluate(tplData)',
'teardown': 'function template(){}'
})
);
@@ -1342,74 +1221,70 @@
suites.push(
Benchmark.Suite('`_.times`')
- .add('Lo-Dash', function() {
- var result = [];
- lodash.times(length, function(n) { result.push(n); });
- })
- .add('Underscore', function() {
- var result = [];
- _.times(length, function(n) { result.push(n); });
- })
+ .add('Lo-Dash', '\
+ var result = [];\
+ lodash.times(length, function(n) { result.push(n); })'
+ )
+ .add('Underscore', '\
+ var result = [];\
+ _.times(length, function(n) { result.push(n); })'
+ )
);
suites.push(
Benchmark.Suite('`_.times` with `thisArg`')
- .add('Lo-Dash', function() {
- var result = [];
- lodash.times(length, function(n) { result.push(this.sin(n)); }, Math);
- })
- .add('Underscore', function() {
- var result = [];
- _.times(length, function(n) { result.push(this.sin(n)); }, Math);
- })
+ .add('Lo-Dash', '\
+ var result = [];\
+ lodash.times(length, function(n) { result.push(this.sin(n)); }, Math)'
+ )
+ .add('Underscore', '\
+ var result = [];\
+ _.times(length, function(n) { result.push(this.sin(n)); }, Math)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.toArray` with an array')
- .add('Lo-Dash', function() {
- lodash.toArray(numbers);
- })
- .add('Underscore', function() {
- _.toArray(numbers);
- })
+ .add('Lo-Dash', '\
+ lodash.toArray(numbers)'
+ )
+ .add('Underscore', '\
+ _.toArray(numbers)'
+ )
);
suites.push(
Benchmark.Suite('`_.toArray` with an object')
- .add('Lo-Dash', function() {
- lodash.toArray(object);
- })
- .add('Underscore', function() {
- _.toArray(object);
- })
+ .add('Lo-Dash', '\
+ lodash.toArray(object)'
+ )
+ .add('Underscore', '\
+ _.toArray(object)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.union`')
- .add('Lo-Dash', function() {
- lodash.union(numbers, fourNumbers, twoNumbers);
- })
- .add('Underscore', function() {
- _.union(numbers, fourNumbers, twoNumbers);
- })
+ .add('Lo-Dash', '\
+ lodash.union(numbers, fourNumbers, twoNumbers)'
+ )
+ .add('Underscore', '\
+ _.union(numbers, fourNumbers, twoNumbers)'
+ )
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 25 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.union(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': 'lodash.union(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.union(twentyFiveValues, twentyFiveValues2);
- },
+ 'fn': '_.union(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -1417,15 +1292,11 @@
suites.push(
Benchmark.Suite('`_.union` iterating an array of 50 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.union(fiftyValues, fiftyValues2);
- },
+ 'fn': 'lodash.union(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.union(fiftyValues, fiftyValues2);
- },
+ 'fn': '_.union(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -1433,15 +1304,11 @@
suites.push(
Benchmark.Suite('`_.union` iterating an array of 75 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.union(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': 'lodash.union(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.union(seventyFiveValues, seventyFiveValues2);
- },
+ 'fn': '_.union(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
@@ -1450,64 +1317,60 @@
suites.push(
Benchmark.Suite('`_.uniq`')
- .add('Lo-Dash', function() {
- lodash.uniq(numbers.concat(fourNumbers, twoNumbers));
- })
- .add('Underscore', function() {
- _.uniq(numbers.concat(fourNumbers, twoNumbers));
- })
+ .add('Lo-Dash', '\
+ lodash.uniq(numbers.concat(fourNumbers, twoNumbers))'
+ )
+ .add('Underscore', '\
+ _.uniq(numbers.concat(fourNumbers, twoNumbers))'
+ )
);
suites.push(
Benchmark.Suite('`_.uniq` with `callback`')
- .add('Lo-Dash', function() {
- lodash.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {
- return num % 2;
- });
- })
- .add('Underscore', function() {
- _.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {
- return num % 2;
- });
- })
+ .add('Lo-Dash', '\
+ lodash.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\
+ return num % 2;\
+ });'
+ )
+ .add('Underscore', '\
+ _.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\
+ return num % 2;\
+ })'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.values`')
- .add('Lo-Dash', function() {
- lodash.values(object);
- })
- .add('Underscore', function() {
- _.values(object);
- })
+ .add('Lo-Dash', '\
+ lodash.values(object)'
+ )
+ .add('Underscore', '\
+ _.values(object)'
+ )
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.without`')
- .add('Lo-Dash', function() {
- lodash.without(numbers, 9, 12, 14, 15);
- })
- .add('Underscore', function() {
- _.without(numbers, 9, 12, 14, 15);
- })
+ .add('Lo-Dash', '\
+ lodash.without(numbers, 9, 12, 14, 15)'
+ )
+ .add('Underscore', '\
+ _.without(numbers, 9, 12, 14, 15)'
+ )
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 25 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));
- },
+ 'fn': 'lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));
- },
+ 'fn': '_.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
);
@@ -1515,15 +1378,11 @@
suites.push(
Benchmark.Suite('`_.without` iterating an array of 50 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.without.apply(lodash, [fiftyValues].concat(fiftyValues2));
- },
+ 'fn': 'lodash.without.apply(lodash, [fiftyValues].concat(fiftyValues2));',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.without.apply(_, [fiftyValues].concat(fiftyValues2));
- },
+ 'fn': '_.without.apply(_, [fiftyValues].concat(fiftyValues2));',
'teardown': 'function multiArrays(){}'
})
);
@@ -1531,15 +1390,11 @@
suites.push(
Benchmark.Suite('`_.without` iterating an array of 75 elements')
.add('Lo-Dash', {
- 'fn': function() {
- lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));
- },
+ 'fn': 'lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
- 'fn': function() {
- _.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));
- },
+ 'fn': '_.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
);
@@ -1547,7 +1402,7 @@
/*--------------------------------------------------------------------------*/
if (Benchmark.platform + '') {
- log(Benchmark.platform + '');
+ log(Benchmark.platform);
}
// in the browser, expose `run` to be called later