Skip to main content
Module

x/lodash/perf/perf.js

A modern JavaScript utility library delivering modularity, performance, & extras.
Extremely Popular
Latest
File
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979
;(function() { 'use strict';
/** Used to access the Firebug Lite panel (set by `run`). */ var fbPanel;
/** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined;
/** Used as a reference to the global object. */ var root = typeof global == 'object' && global || this;
/** Method and object shortcuts. */ var phantom = root.phantom, amd = root.define && define.amd, argv = root.process && process.argv, document = !phantom && root.document, noop = function() {}, params = root.arguments, system = root.system;
/** Add `console.log()` support for Rhino and RingoJS. */ var console = root.console || (root.console = { 'log': root.print });
/** The file path of the lodash file to test. */ var filePath = (function() { var min = 0, result = [];
if (phantom) { result = params = phantom.args; } else if (system) { min = 1; result = params = system.args; } else if (argv) { min = 2; result = params = argv; } else if (params) { result = params; } var last = result[result.length - 1]; result = (result.length > min && !/perf(?:\.js)?$/.test(last)) ? last : '../lodash.js';
if (!amd) { try { result = require('fs').realpathSync(result); } catch (e) {}
try { result = require.resolve(result); } catch (e) {} } return result; }());
/** Used to match path separators. */ var rePathSeparator = /[\/\\]/;
/** Used to detect primitive types. */ var rePrimitive = /^(?:boolean|number|string|undefined)$/;
/** Used to match RegExp special characters. */ var reSpecialChars = /[.*+?^=!:${}()|[\]\/\\]/g;
/** The `ui` object. */ var ui = root.ui || (root.ui = { 'buildPath': basename(filePath, '.js'), 'otherPath': 'underscore' });
/** The lodash build basename. */ var buildName = root.buildName = basename(ui.buildPath, '.js');
/** The other library basename. */ var otherName = root.otherName = (function() { var result = basename(ui.otherPath, '.js'); return result + (result == buildName ? ' (2)' : ''); }());
/** Used to score performance. */ var score = { 'a': [], 'b': [] };
/** Used to queue benchmark suites. */ var suites = [];
/** Use a single "load" function. */ var load = (typeof require == 'function' && !amd) ? require : noop;
/** Load lodash. */ var lodash = root.lodash || (root.lodash = ( lodash = load(filePath) || root._, lodash = lodash._ || lodash, (lodash.runInContext ? lodash.runInContext(root) : lodash), lodash.noConflict() ));
/** Load Underscore. */ var _ = root.underscore || (root.underscore = ( _ = load('../vendor/underscore/underscore.js') || root._, _._ || _ ));
/** Load Benchmark.js. */ var Benchmark = root.Benchmark || (root.Benchmark = ( Benchmark = load('../node_modules/benchmark/benchmark.js') || root.Benchmark, Benchmark = Benchmark.Benchmark || Benchmark, Benchmark.runInContext(lodash.extend({}, root, { '_': lodash })) ));
/*--------------------------------------------------------------------------*/
/** * Gets the basename of the given `filePath`. If the file `extension` is passed, * it will be removed from the basename. * * @private * @param {string} path The file path to inspect. * @param {string} extension The extension to remove. * @returns {string} Returns the basename. */ function basename(filePath, extension) { var result = (filePath || '').split(rePathSeparator).pop(); return (arguments.length < 2) ? result : result.replace(RegExp(extension.replace(reSpecialChars, '\\$&') + '$'), ''); }
/** * Computes the geometric mean (log-average) of an array of values. * See http://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms. * * @private * @param {Array} array The array of values. * @returns {number} The geometric mean. */ function getGeometricMean(array) { return Math.pow(Math.E, lodash.reduce(array, function(sum, x) { return sum + Math.log(x); }, 0) / array.length) || 0; }
/** * Gets the Hz, i.e. operations per second, of `bench` adjusted for the * margin of error. * * @private * @param {Object} bench The benchmark object. * @returns {number} Returns the adjusted Hz. */ function getHz(bench) { var result = 1 / (bench.stats.mean + bench.stats.moe); return isFinite(result) ? result : 0; }
/** * Host objects can return type values that are different from their actual * data type. The objects we are concerned with usually return non-primitive * types of "object", "function", or "unknown". * * @private * @param {*} object The owner of the property. * @param {string} property The property to check. * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`. */ function isHostType(object, property) { if (object == null) { return false; } var type = typeof object[property]; return !rePrimitive.test(type) && (type != 'object' || !!object[property]); }
/** * Logs text to the console. * * @private * @param {string} text The text to log. */ function log(text) { console.log(text + ''); if (fbPanel) { // Scroll the Firebug Lite panel down. fbPanel.scrollTop = fbPanel.scrollHeight; } }
/** * Runs all benchmark suites. * * @private (@public in the browser) */ function run() { fbPanel = (fbPanel = root.document && document.getElementById('FirebugUI')) && (fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) && fbPanel.getElementById('fbPanel1');
log('\nSit back and relax, this may take a while.'); suites[0].run({ 'async': true }); }
/*--------------------------------------------------------------------------*/
lodash.extend(Benchmark.Suite.options, { 'onStart': function() { log('\n' + this.name + ':'); }, 'onCycle': function(event) { log(event.target); }, 'onComplete': function() { for (var index = 0, length = this.length; index < length; index++) { var bench = this[index]; if (bench.error) { var errored = true; } } if (errored) { log('There was a problem, skipping...'); } else { var formatNumber = Benchmark.formatNumber, fastest = this.filter('fastest'), fastestHz = getHz(fastest[0]), slowest = this.filter('slowest'), slowestHz = getHz(slowest[0]), aHz = getHz(this[0]), bHz = getHz(this[1]);
if (fastest.length > 1) { log('It\'s too close to call.'); aHz = bHz = slowestHz; } else { var percent = ((fastestHz / slowestHz) - 1) * 100;
log( fastest[0].name + ' is ' + formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) + '% faster.' ); } // Add score adjusted for margin of error. score.a.push(aHz); score.b.push(bHz); } // Remove current suite from queue. suites.shift();
if (suites.length) { // Run next suite. suites[0].run({ 'async': true }); } else { var aMeanHz = getGeometricMean(score.a), bMeanHz = getGeometricMean(score.b), fastestMeanHz = Math.max(aMeanHz, bMeanHz), slowestMeanHz = Math.min(aMeanHz, bMeanHz), xFaster = fastestMeanHz / slowestMeanHz, percentFaster = formatNumber(Math.round((xFaster - 1) * 100)), message = 'is ' + percentFaster + '% ' + (xFaster == 1 ? '' : '(' + formatNumber(xFaster.toFixed(2)) + 'x) ') + 'faster than';
// Report results. if (aMeanHz >= bMeanHz) { log('\n' + buildName + ' ' + message + ' ' + otherName + '.'); } else { log('\n' + otherName + ' ' + message + ' ' + buildName + '.'); } } } });
/*--------------------------------------------------------------------------*/
lodash.extend(Benchmark.options, { 'async': true, 'setup': '\ var _ = global.underscore,\ lodash = global.lodash,\ belt = this.name == buildName ? lodash : _;\ \ var date = new Date,\ limit = 50,\ regexp = /x/,\ object = {},\ objects = Array(limit),\ numbers = Array(limit),\ fourNumbers = [5, 25, 10, 30],\ nestedNumbers = [1, [2], [3, [[4]]]],\ nestedObjects = [{}, [{}], [{}, [[{}]]]],\ twoNumbers = [12, 23];\ \ for (var index = 0; index < limit; index++) {\ numbers[index] = index;\ object["key" + index] = index;\ objects[index] = { "num": index };\ }\ var strNumbers = numbers + "";\ \ if (typeof assign != "undefined") {\ var _assign = _.assign || _.extend,\ lodashAssign = lodash.assign;\ }\ if (typeof bind != "undefined") {\ var thisArg = { "name": "fred" };\ \ var func = function(greeting, punctuation) {\ return (greeting || "hi") + " " + this.name + (punctuation || ".");\ };\ \ var _boundNormal = _.bind(func, thisArg),\ _boundMultiple = _boundNormal,\ _boundPartial = _.bind(func, thisArg, "hi");\ \ var lodashBoundNormal = lodash.bind(func, thisArg),\ lodashBoundMultiple = lodashBoundNormal,\ lodashBoundPartial = lodash.bind(func, thisArg, "hi");\ \ for (index = 0; index < 10; index++) {\ _boundMultiple = _.bind(_boundMultiple, { "name": "fred" + index });\ lodashBoundMultiple = lodash.bind(lodashBoundMultiple, { "name": "fred" + index });\ }\ }\ if (typeof bindAll != "undefined") {\ var bindAllCount = -1,\ bindAllObjects = Array(this.count);\ \ var funcNames = belt.reject(belt.functions(belt).slice(0, 40), function(funcName) {\ return /^_/.test(funcName);\ });\ \ // Potentially expensive.\n\ for (index = 0; index < this.count; index++) {\ bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\ object[funcName] = belt[funcName];\ return object;\ }, {});\ }\ }\ if (typeof chaining != "undefined") {\ var even = function(v) { return v % 2 == 0; },\ square = function(v) { return v * v; };\ \ var largeArray = belt.range(10000),\ _chaining = _(largeArray).chain(),\ lodashChaining = lodash(largeArray).chain();\ }\ if (typeof compact != "undefined") {\ var uncompacted = numbers.slice();\ uncompacted[2] = false;\ uncompacted[6] = null;\ uncompacted[18] = "";\ }\ if (typeof flowRight != "undefined") {\ var compAddOne = function(n) { return n + 1; },\ compAddTwo = function(n) { return n + 2; },\ compAddThree = function(n) { return n + 3; };\ \ var _composed = _.flowRight && _.flowRight(compAddThree, compAddTwo, compAddOne),\ lodashComposed = lodash.flowRight && lodash.flowRight(compAddThree, compAddTwo, compAddOne);\ }\ if (typeof countBy != "undefined" || typeof omit != "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,\ "twenty-six": 26,\ "twenty-seven": 27,\ "twenty-eight": 28,\ "twenty-nine": 29,\ "thirty": 30,\ "thirty-one": 31,\ "thirty-two": 32,\ "thirty-three": 33,\ "thirty-four": 34,\ "thirty-five": 35,\ "thirty-six": 36,\ "thirty-seven": 37,\ "thirty-eight": 38,\ "thirty-nine": 39,\ "forty": 40\ };\ \ var words = belt.keys(wordToNumber).slice(0, limit);\ }\ if (typeof flatten != "undefined") {\ var _flattenDeep = _.flatten([[1]])[0] !== 1,\ lodashFlattenDeep = lodash.flatten([[1]])[0] !== 1;\ }\ 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 objectOfObjects2 = {\ "boolean": new Boolean(true),\ "number": new Number(1),\ "string": new String("A")\ };\ \ var object2 = {},\ object3 = {},\ objects2 = Array(limit),\ objects3 = Array(limit),\ numbers2 = Array(limit),\ numbers3 = Array(limit),\ nestedNumbers2 = [1, [2], [3, [[4]]]],\ nestedNumbers3 = [1, [2], [3, [[6]]]];\ \ for (index = 0; index < limit; index++) {\ object2["key" + index] = index;\ object3["key" + index] = index;\ objects2[index] = { "num": index };\ objects3[index] = { "num": index };\ numbers2[index] = index;\ numbers3[index] = index;\ }\ object3["key" + (limit - 1)] = -1;\ objects3[limit - 1].num = -1;\ numbers3[limit - 1] = -1;\ }\ if (typeof matches != "undefined") {\ var source = { "num": 9 };\ \ var _matcher = (_.matches || _.noop)(source),\ lodashMatcher = (lodash.matches || lodash.noop)(source);\ }\ if (typeof multiArrays != "undefined") {\ var twentyValues = belt.shuffle(belt.range(20)),\ fortyValues = belt.shuffle(belt.range(40)),\ hundredSortedValues = belt.range(100),\ hundredValues = belt.shuffle(hundredSortedValues),\ hundredValues2 = belt.shuffle(hundredValues),\ hundredTwentyValues = belt.shuffle(belt.range(120)),\ hundredTwentyValues2 = belt.shuffle(hundredTwentyValues),\ twoHundredValues = belt.shuffle(belt.range(200)),\ twoHundredValues2 = belt.shuffle(twoHundredValues);\ }\ if (typeof partial != "undefined") {\ var func = function(greeting, punctuation) {\ return greeting + " fred" + (punctuation || ".");\ };\ \ var _partial = _.partial(func, "hi"),\ lodashPartial = lodash.partial(func, "hi");\ }\ 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 tpl =\ "<div>" +\ "<h1 class=\'header1\'><%= header1 %></h1>" +\ "<h2 class=\'header2\'><%= header2 %></h2>" +\ "<h3 class=\'header3\'><%= header3 %></h3>" +\ "<h4 class=\'header4\'><%= header4 %></h4>" +\ "<h5 class=\'header5\'><%= header5 %></h5>" +\ "<h6 class=\'header6\'><%= header6 %></h6>" +\ "<ul class=\'list\'>" +\ "<% for (var index = 0, length = list.length; index < length; index++) { %>" +\ "<li class=\'item\'><%= list[index] %></li>" +\ "<% } %>" +\ "</ul>" +\ "</div>";\ \ var tplVerbose =\ "<div>" +\ "<h1 class=\'header1\'><%= data.header1 %></h1>" +\ "<h2 class=\'header2\'><%= data.header2 %></h2>" +\ "<h3 class=\'header3\'><%= data.header3 %></h3>" +\ "<h4 class=\'header4\'><%= data.header4 %></h4>" +\ "<h5 class=\'header5\'><%= data.header5 %></h5>" +\ "<h6 class=\'header6\'><%= data.header6 %></h6>" +\ "<ul class=\'list\'>" +\ "<% for (var index = 0, length = data.list.length; index < length; index++) { %>" +\ "<li class=\'item\'><%= data.list[index] %></li>" +\ "<% } %>" +\ "</ul>" +\ "</div>";\ \ var settingsObject = { "variable": "data" };\ \ var _tpl = _.template(tpl),\ _tplVerbose = _.template(tplVerbose, null, settingsObject);\ \ var lodashTpl = lodash.template(tpl),\ lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject);\ }\ if (typeof wrap != "undefined") {\ var add = function(a, b) {\ return a + b;\ };\ \ var average = function(func, a, b) {\ return (func(a, b) / 2).toFixed(2);\ };\ \ var _wrapped = _.wrap(add, average);\ lodashWrapped = lodash.wrap(add, average);\ }\ if (typeof zip != "undefined") {\ var unzipped = [["a", "b", "c"], [1, 2, 3], [true, false, true]];\ }' });
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_(...).map(...).filter(...).take(...).value()`') .add(buildName, { 'fn': 'lodashChaining.map(square).filter(even).take(100).value()', 'teardown': 'function chaining(){}' }) .add(otherName, { 'fn': '_chaining.map(square).filter(even).take(100).value()', 'teardown': 'function chaining(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.assign`') .add(buildName, { 'fn': 'lodashAssign({}, { "a": 1, "b": 2, "c": 3 })', 'teardown': 'function assign(){}' }) .add(otherName, { 'fn': '_assign({}, { "a": 1, "b": 2, "c": 3 })', 'teardown': 'function assign(){}' }) );
suites.push( Benchmark.Suite('`_.assign` with multiple sources') .add(buildName, { 'fn': 'lodashAssign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })', 'teardown': 'function assign(){}' }) .add(otherName, { 'fn': '_assign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })', 'teardown': 'function assign(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.bind` (slow path)') .add(buildName, { 'fn': 'lodash.bind(function() { return this.name; }, { "name": "fred" })', 'teardown': 'function bind(){}' }) .add(otherName, { 'fn': '_.bind(function() { return this.name; }, { "name": "fred" })', 'teardown': 'function bind(){}' }) );
suites.push( Benchmark.Suite('bound call with arguments') .add(buildName, { 'fn': 'lodashBoundNormal("hi", "!")', 'teardown': 'function bind(){}' }) .add(otherName, { 'fn': '_boundNormal("hi", "!")', 'teardown': 'function bind(){}' }) );
suites.push( Benchmark.Suite('bound and partially applied call with arguments') .add(buildName, { 'fn': 'lodashBoundPartial("!")', 'teardown': 'function bind(){}' }) .add(otherName, { 'fn': '_boundPartial("!")', 'teardown': 'function bind(){}' }) );
suites.push( Benchmark.Suite('bound multiple times') .add(buildName, { 'fn': 'lodashBoundMultiple()', 'teardown': 'function bind(){}' }) .add(otherName, { 'fn': '_boundMultiple()', 'teardown': 'function bind(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.bindAll`') .add(buildName, { 'fn': 'lodash.bindAll(bindAllObjects[++bindAllCount], funcNames)', 'teardown': 'function bindAll(){}' }) .add(otherName, { 'fn': '_.bindAll(bindAllObjects[++bindAllCount], funcNames)', 'teardown': 'function bindAll(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.clone` with an array') .add(buildName, '\ lodash.clone(numbers)' ) .add(otherName, '\ _.clone(numbers)' ) );
suites.push( Benchmark.Suite('`_.clone` with an object') .add(buildName, '\ lodash.clone(object)' ) .add(otherName, '\ _.clone(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.compact`') .add(buildName, { 'fn': 'lodash.compact(uncompacted)', 'teardown': 'function compact(){}' }) .add(otherName, { 'fn': '_.compact(uncompacted)', 'teardown': 'function compact(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.countBy` with `callback` iterating an array') .add(buildName, '\ lodash.countBy(numbers, function(num) { return num >> 1; })' ) .add(otherName, '\ _.countBy(numbers, function(num) { return num >> 1; })' ) );
suites.push( Benchmark.Suite('`_.countBy` with `property` name iterating an array') .add(buildName, { 'fn': 'lodash.countBy(words, "length")', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '_.countBy(words, "length")', 'teardown': 'function countBy(){}' }) );
suites.push( Benchmark.Suite('`_.countBy` with `callback` iterating an object') .add(buildName, { 'fn': 'lodash.countBy(wordToNumber, function(num) { return num >> 1; })', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '_.countBy(wordToNumber, function(num) { return num >> 1; })', 'teardown': 'function countBy(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.defaults`') .add(buildName, '\ lodash.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)' ) .add(otherName, '\ _.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.difference`') .add(buildName, '\ lodash.difference(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ _.difference(numbers, twoNumbers, fourNumbers)' ) );
suites.push( Benchmark.Suite('`_.difference` iterating 20 and 40 elements') .add(buildName, { 'fn': 'lodash.difference(twentyValues, fortyValues)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.difference(twentyValues, fortyValues)', 'teardown': 'function multiArrays(){}' }) );
suites.push( Benchmark.Suite('`_.difference` iterating 200 elements') .add(buildName, { 'fn': 'lodash.difference(twoHundredValues, twoHundredValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.difference(twoHundredValues, twoHundredValues2)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.each` iterating an array') .add(buildName, '\ var result = [];\ lodash.each(numbers, function(num) {\ result.push(num * 2);\ })' ) .add(otherName, '\ var result = [];\ _.each(numbers, function(num) {\ result.push(num * 2);\ })' ) );
suites.push( Benchmark.Suite('`_.each` iterating an object') .add(buildName, '\ var result = [];\ lodash.each(object, function(num) {\ result.push(num * 2);\ })' ) .add(otherName, '\ var result = [];\ _.each(object, function(num) {\ result.push(num * 2);\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.every` iterating an array') .add(buildName, '\ lodash.every(numbers, function(num) {\ return num < limit;\ })' ) .add(otherName, '\ _.every(numbers, function(num) {\ return num < limit;\ })' ) );
suites.push( Benchmark.Suite('`_.every` iterating an object') .add(buildName, '\ lodash.every(object, function(num) {\ return num < limit;\ })' ) .add(otherName, '\ _.every(object, function(num) {\ return num < limit;\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.filter` iterating an array') .add(buildName, '\ lodash.filter(numbers, function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.filter(numbers, function(num) {\ return num % 2;\ })' ) );
suites.push( Benchmark.Suite('`_.filter` iterating an object') .add(buildName, '\ lodash.filter(object, function(num) {\ return num % 2\ })' ) .add(otherName, '\ _.filter(object, function(num) {\ return num % 2\ })' ) );
suites.push( Benchmark.Suite('`_.filter` with `_.matches` shorthand') .add(buildName, { 'fn': 'lodash.filter(objects, source)', 'teardown': 'function matches(){}' }) .add(otherName, { 'fn': '_.filter(objects, source)', 'teardown': 'function matches(){}' }) );
suites.push( Benchmark.Suite('`_.filter` with `_.matches` predicate') .add(buildName, { 'fn': 'lodash.filter(objects, lodashMatcher)', 'teardown': 'function matches(){}' }) .add(otherName, { 'fn': '_.filter(objects, _matcher)', 'teardown': 'function matches(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.find` iterating an array') .add(buildName, '\ lodash.find(numbers, function(num) {\ return num === (limit - 1);\ })' ) .add(otherName, '\ _.find(numbers, function(num) {\ return num === (limit - 1);\ })' ) );
suites.push( Benchmark.Suite('`_.find` iterating an object') .add(buildName, '\ lodash.find(object, function(value, key) {\ return /\D9$/.test(key);\ })' ) .add(otherName, '\ _.find(object, function(value, key) {\ return /\D9$/.test(key);\ })' ) );
// Avoid Underscore induced `OutOfMemoryError` in Rhino and Ringo. suites.push( Benchmark.Suite('`_.find` with `_.matches` shorthand') .add(buildName, { 'fn': 'lodash.find(objects, source)', 'teardown': 'function matches(){}' }) .add(otherName, { 'fn': '_.find(objects, source)', 'teardown': 'function matches(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.flatten`') .add(buildName, { 'fn': 'lodash.flatten(nestedNumbers, !lodashFlattenDeep)', 'teardown': 'function flatten(){}' }) .add(otherName, { 'fn': '_.flatten(nestedNumbers, !_flattenDeep)', 'teardown': 'function flatten(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.flattenDeep` nested arrays of numbers') .add(buildName, { 'fn': 'lodash.flattenDeep(nestedNumbers)', 'teardown': 'function flatten(){}' }) .add(otherName, { 'fn': '_.flattenDeep(nestedNumbers)', 'teardown': 'function flatten(){}' }) );
suites.push( Benchmark.Suite('`_.flattenDeep` nest arrays of objects') .add(buildName, { 'fn': 'lodash.flattenDeep(nestedObjects)', 'teardown': 'function flatten(){}' }) .add(otherName, { 'fn': '_.flattenDeep(nestedObjects)', 'teardown': 'function flatten(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.flowRight`') .add(buildName, { 'fn': 'lodash.flowRight(compAddThree, compAddTwo, compAddOne)', 'teardown': 'function flowRight(){}' }) .add(otherName, { 'fn': '_.flowRight(compAddThree, compAddTwo, compAddOne)', 'teardown': 'function flowRight(){}' }) );
suites.push( Benchmark.Suite('composed call') .add(buildName, { 'fn': 'lodashComposed(0)', 'teardown': 'function flowRight(){}' }) .add(otherName, { 'fn': '_composed(0)', 'teardown': 'function flowRight(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.functions`') .add(buildName, '\ lodash.functions(lodash)' ) .add(otherName, '\ _.functions(lodash)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.groupBy` with `callback` iterating an array') .add(buildName, '\ lodash.groupBy(numbers, function(num) { return num >> 1; })' ) .add(otherName, '\ _.groupBy(numbers, function(num) { return num >> 1; })' ) );
suites.push( Benchmark.Suite('`_.groupBy` with `property` name iterating an array') .add(buildName, { 'fn': 'lodash.groupBy(words, "length")', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '_.groupBy(words, "length")', 'teardown': 'function countBy(){}' }) );
suites.push( Benchmark.Suite('`_.groupBy` with `callback` iterating an object') .add(buildName, { 'fn': 'lodash.groupBy(wordToNumber, function(num) { return num >> 1; })', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '_.groupBy(wordToNumber, function(num) { return num >> 1; })', 'teardown': 'function countBy(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.includes` searching an array') .add(buildName, '\ lodash.includes(numbers, limit - 1)' ) .add(otherName, '\ _.includes(numbers, limit - 1)' ) );
suites.push( Benchmark.Suite('`_.includes` searching an object') .add(buildName, '\ lodash.includes(object, limit - 1)' ) .add(otherName, '\ _.includes(object, limit - 1)' ) );
if (lodash.includes('ab', 'ab') && _.includes('ab', 'ab')) { suites.push( Benchmark.Suite('`_.includes` searching a string') .add(buildName, '\ lodash.includes(strNumbers, "," + (limit - 1))' ) .add(otherName, '\ _.includes(strNumbers, "," + (limit - 1))' ) ); }
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.indexOf`') .add(buildName, { 'fn': 'lodash.indexOf(hundredSortedValues, 99)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.indexOf(hundredSortedValues, 99)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.intersection`') .add(buildName, '\ lodash.intersection(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ _.intersection(numbers, twoNumbers, fourNumbers)' ) );
suites.push( Benchmark.Suite('`_.intersection` iterating 120 elements') .add(buildName, { 'fn': 'lodash.intersection(hundredTwentyValues, hundredTwentyValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.intersection(hundredTwentyValues, hundredTwentyValues2)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.invert`') .add(buildName, '\ lodash.invert(object)' ) .add(otherName, '\ _.invert(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.invokeMap` iterating an array') .add(buildName, '\ lodash.invokeMap(numbers, "toFixed")' ) .add(otherName, '\ _.invokeMap(numbers, "toFixed")' ) );
suites.push( Benchmark.Suite('`_.invokeMap` with arguments iterating an array') .add(buildName, '\ lodash.invokeMap(numbers, "toFixed", 1)' ) .add(otherName, '\ _.invokeMap(numbers, "toFixed", 1)' ) );
suites.push( Benchmark.Suite('`_.invokeMap` with a function for `path` iterating an array') .add(buildName, '\ lodash.invokeMap(numbers, Number.prototype.toFixed, 1)' ) .add(otherName, '\ _.invokeMap(numbers, Number.prototype.toFixed, 1)' ) );
suites.push( Benchmark.Suite('`_.invokeMap` iterating an object') .add(buildName, '\ lodash.invokeMap(object, "toFixed", 1)' ) .add(otherName, '\ _.invokeMap(object, "toFixed", 1)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.isEqual` comparing primitives') .add(buildName, { 'fn': '\ lodash.isEqual(1, "1");\ lodash.isEqual(1, 1)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(1, "1");\ _.isEqual(1, 1);', 'teardown': 'function isEqual(){}' }) );
suites.push( Benchmark.Suite('`_.isEqual` comparing primitives and their object counterparts (edge case)') .add(buildName, { 'fn': '\ lodash.isEqual(objectOfPrimitives, objectOfObjects);\ lodash.isEqual(objectOfPrimitives, objectOfObjects2)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(objectOfPrimitives, objectOfObjects);\ _.isEqual(objectOfPrimitives, objectOfObjects2)', 'teardown': 'function isEqual(){}' }) );
suites.push( Benchmark.Suite('`_.isEqual` comparing arrays') .add(buildName, { 'fn': '\ lodash.isEqual(numbers, numbers2);\ lodash.isEqual(numbers2, numbers3)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(numbers, numbers2);\ _.isEqual(numbers2, numbers3)', 'teardown': 'function isEqual(){}' }) );
suites.push( Benchmark.Suite('`_.isEqual` comparing nested arrays') .add(buildName, { 'fn': '\ lodash.isEqual(nestedNumbers, nestedNumbers2);\ lodash.isEqual(nestedNumbers2, nestedNumbers3)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(nestedNumbers, nestedNumbers2);\ _.isEqual(nestedNumbers2, nestedNumbers3)', 'teardown': 'function isEqual(){}' }) );
suites.push( Benchmark.Suite('`_.isEqual` comparing arrays of objects') .add(buildName, { 'fn': '\ lodash.isEqual(objects, objects2);\ lodash.isEqual(objects2, objects3)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(objects, objects2);\ _.isEqual(objects2, objects3)', 'teardown': 'function isEqual(){}' }) );
suites.push( Benchmark.Suite('`_.isEqual` comparing objects') .add(buildName, { 'fn': '\ lodash.isEqual(object, object2);\ lodash.isEqual(object2, object3)', 'teardown': 'function isEqual(){}' }) .add(otherName, { 'fn': '\ _.isEqual(object, object2);\ _.isEqual(object2, object3)', 'teardown': 'function isEqual(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isObject`, `_.isRegExp`') .add(buildName, '\ lodash.isArguments(arguments);\ lodash.isArguments(object);\ lodash.isDate(date);\ lodash.isDate(object);\ lodash.isFunction(lodash);\ lodash.isFunction(object);\ lodash.isNumber(1);\ lodash.isNumber(object);\ lodash.isObject(object);\ lodash.isObject(1);\ lodash.isRegExp(regexp);\ lodash.isRegExp(object)' ) .add(otherName, '\ _.isArguments(arguments);\ _.isArguments(object);\ _.isDate(date);\ _.isDate(object);\ _.isFunction(_);\ _.isFunction(object);\ _.isNumber(1);\ _.isNumber(object);\ _.isObject(object);\ _.isObject(1);\ _.isRegExp(regexp);\ _.isRegExp(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)') .add(buildName, '\ lodash.keys(object)' ) .add(otherName, '\ _.keys(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.lastIndexOf`') .add(buildName, { 'fn': 'lodash.lastIndexOf(hundredSortedValues, 0)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.lastIndexOf(hundredSortedValues, 0)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.map` iterating an array') .add(buildName, '\ lodash.map(objects, function(value) {\ return value.num;\ })' ) .add(otherName, '\ _.map(objects, function(value) {\ return value.num;\ })' ) );
suites.push( Benchmark.Suite('`_.map` iterating an object') .add(buildName, '\ lodash.map(object, function(value) {\ return value;\ })' ) .add(otherName, '\ _.map(object, function(value) {\ return value;\ })' ) );
suites.push( Benchmark.Suite('`_.map` with `_.property` shorthand') .add(buildName, '\ lodash.map(objects, "num")' ) .add(otherName, '\ _.map(objects, "num")' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.max`') .add(buildName, '\ lodash.max(numbers)' ) .add(otherName, '\ _.max(numbers)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.min`') .add(buildName, '\ lodash.min(numbers)' ) .add(otherName, '\ _.min(numbers)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.omit` iterating 20 properties, omitting 2 keys') .add(buildName, '\ lodash.omit(object, "key6", "key13")' ) .add(otherName, '\ _.omit(object, "key6", "key13")' ) );
suites.push( Benchmark.Suite('`_.omit` iterating 40 properties, omitting 20 keys') .add(buildName, { 'fn': 'lodash.omit(wordToNumber, words)', 'teardown': 'function omit(){}' }) .add(otherName, { 'fn': '_.omit(wordToNumber, words)', 'teardown': 'function omit(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.partial` (slow path)') .add(buildName, { 'fn': 'lodash.partial(function(greeting) { return greeting + " " + this.name; }, "hi")', 'teardown': 'function partial(){}' }) .add(otherName, { 'fn': '_.partial(function(greeting) { return greeting + " " + this.name; }, "hi")', 'teardown': 'function partial(){}' }) );
suites.push( Benchmark.Suite('partially applied call with arguments') .add(buildName, { 'fn': 'lodashPartial("!")', 'teardown': 'function partial(){}' }) .add(otherName, { 'fn': '_partial("!")', 'teardown': 'function partial(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.partition` iterating an array') .add(buildName, '\ lodash.partition(numbers, function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.partition(numbers, function(num) {\ return num % 2;\ })' ) );
suites.push( Benchmark.Suite('`_.partition` iterating an object') .add(buildName, '\ lodash.partition(object, function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.partition(object, function(num) {\ return num % 2;\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.pick`') .add(buildName, '\ lodash.pick(object, "key6", "key13")' ) .add(otherName, '\ _.pick(object, "key6", "key13")' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.reduce` iterating an array') .add(buildName, '\ lodash.reduce(numbers, function(result, value, index) {\ result[index] = value;\ return result;\ }, {})' ) .add(otherName, '\ _.reduce(numbers, function(result, value, index) {\ result[index] = value;\ return result;\ }, {})' ) );
suites.push( Benchmark.Suite('`_.reduce` iterating an object') .add(buildName, '\ lodash.reduce(object, function(result, value, key) {\ result.push(key, value);\ return result;\ }, [])' ) .add(otherName, '\ _.reduce(object, function(result, value, key) {\ result.push(key, value);\ return result;\ }, [])' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.reduceRight` iterating an array') .add(buildName, '\ lodash.reduceRight(numbers, function(result, value, index) {\ result[index] = value;\ return result;\ }, {})' ) .add(otherName, '\ _.reduceRight(numbers, function(result, value, index) {\ result[index] = value;\ return result;\ }, {})' ) );
suites.push( Benchmark.Suite('`_.reduceRight` iterating an object') .add(buildName, '\ lodash.reduceRight(object, function(result, value, key) {\ result.push(key, value);\ return result;\ }, [])' ) .add(otherName, '\ _.reduceRight(object, function(result, value, key) {\ result.push(key, value);\ return result;\ }, [])' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.reject` iterating an array') .add(buildName, '\ lodash.reject(numbers, function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.reject(numbers, function(num) {\ return num % 2;\ })' ) );
suites.push( Benchmark.Suite('`_.reject` iterating an object') .add(buildName, '\ lodash.reject(object, function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.reject(object, function(num) {\ return num % 2;\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sampleSize`') .add(buildName, '\ lodash.sampleSize(numbers, limit / 2)' ) .add(otherName, '\ _.sampleSize(numbers, limit / 2)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.shuffle`') .add(buildName, '\ lodash.shuffle(numbers)' ) .add(otherName, '\ _.shuffle(numbers)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.size` with an object') .add(buildName, '\ lodash.size(object)' ) .add(otherName, '\ _.size(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.some` iterating an array') .add(buildName, '\ lodash.some(numbers, function(num) {\ return num == (limit - 1);\ })' ) .add(otherName, '\ _.some(numbers, function(num) {\ return num == (limit - 1);\ })' ) );
suites.push( Benchmark.Suite('`_.some` iterating an object') .add(buildName, '\ lodash.some(object, function(num) {\ return num == (limit - 1);\ })' ) .add(otherName, '\ _.some(object, function(num) {\ return num == (limit - 1);\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sortBy` with `callback`') .add(buildName, '\ lodash.sortBy(numbers, function(num) { return Math.sin(num); })' ) .add(otherName, '\ _.sortBy(numbers, function(num) { return Math.sin(num); })' ) );
suites.push( Benchmark.Suite('`_.sortBy` with `property` name') .add(buildName, { 'fn': 'lodash.sortBy(words, "length")', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '_.sortBy(words, "length")', 'teardown': 'function countBy(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sortedIndex`') .add(buildName, '\ lodash.sortedIndex(numbers, limit)' ) .add(otherName, '\ _.sortedIndex(numbers, limit)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sortedIndexBy`') .add(buildName, { 'fn': '\ lodash.sortedIndexBy(words, "twenty-five", function(value) {\ return wordToNumber[value];\ })', 'teardown': 'function countBy(){}' }) .add(otherName, { 'fn': '\ _.sortedIndexBy(words, "twenty-five", function(value) {\ return wordToNumber[value];\ })', 'teardown': 'function countBy(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sortedIndexOf`') .add(buildName, { 'fn': 'lodash.sortedIndexOf(hundredSortedValues, 99)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.sortedIndexOf(hundredSortedValues, 99)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sortedLastIndexOf`') .add(buildName, { 'fn': 'lodash.sortedLastIndexOf(hundredSortedValues, 0)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.sortedLastIndexOf(hundredSortedValues, 0)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.sum`') .add(buildName, '\ lodash.sum(numbers)' ) .add(otherName, '\ _.sum(numbers)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.template` (slow path)') .add(buildName, { 'fn': 'lodash.template(tpl)(tplData)', 'teardown': 'function template(){}' }) .add(otherName, { 'fn': '_.template(tpl)(tplData)', 'teardown': 'function template(){}' }) );
suites.push( Benchmark.Suite('compiled template') .add(buildName, { 'fn': 'lodashTpl(tplData)', 'teardown': 'function template(){}' }) .add(otherName, { 'fn': '_tpl(tplData)', 'teardown': 'function template(){}' }) );
suites.push( Benchmark.Suite('compiled template without a with-statement') .add(buildName, { 'fn': 'lodashTplVerbose(tplData)', 'teardown': 'function template(){}' }) .add(otherName, { 'fn': '_tplVerbose(tplData)', 'teardown': 'function template(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.times`') .add(buildName, '\ var result = [];\ lodash.times(limit, function(n) { result.push(n); })' ) .add(otherName, '\ var result = [];\ _.times(limit, function(n) { result.push(n); })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.toArray` with an array (edge case)') .add(buildName, '\ lodash.toArray(numbers)' ) .add(otherName, '\ _.toArray(numbers)' ) );
suites.push( Benchmark.Suite('`_.toArray` with an object') .add(buildName, '\ lodash.toArray(object)' ) .add(otherName, '\ _.toArray(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.toPairs`') .add(buildName, '\ lodash.toPairs(object)' ) .add(otherName, '\ _.toPairs(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.unescape` string without html entities') .add(buildName, '\ lodash.unescape("`&`, `<`, `>`, `\\"`, and `\'`")' ) .add(otherName, '\ _.unescape("`&`, `<`, `>`, `\\"`, and `\'`")' ) );
suites.push( Benchmark.Suite('`_.unescape` string with html entities') .add(buildName, '\ lodash.unescape("`&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;`")' ) .add(otherName, '\ _.unescape("`&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;`")' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.union`') .add(buildName, '\ lodash.union(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ _.union(numbers, twoNumbers, fourNumbers)' ) );
suites.push( Benchmark.Suite('`_.union` iterating an array of 200 elements') .add(buildName, { 'fn': 'lodash.union(hundredValues, hundredValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.union(hundredValues, hundredValues2)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.uniq`') .add(buildName, '\ lodash.uniq(numbers.concat(twoNumbers, fourNumbers))' ) .add(otherName, '\ _.uniq(numbers.concat(twoNumbers, fourNumbers))' ) );
suites.push( Benchmark.Suite('`_.uniq` iterating an array of 200 elements') .add(buildName, { 'fn': 'lodash.uniq(twoHundredValues)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { 'fn': '_.uniq(twoHundredValues)', 'teardown': 'function multiArrays(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.uniqBy`') .add(buildName, '\ lodash.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\ return num % 2;\ })' ) .add(otherName, '\ _.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\ return num % 2;\ })' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.values`') .add(buildName, '\ lodash.values(object)' ) .add(otherName, '\ _.values(object)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.without`') .add(buildName, '\ lodash.without(numbers, 9, 12, 14, 15)' ) .add(otherName, '\ _.without(numbers, 9, 12, 14, 15)' ) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.wrap` result called') .add(buildName, { 'fn': 'lodashWrapped(2, 5)', 'teardown': 'function wrap(){}' }) .add(otherName, { 'fn': '_wrapped(2, 5)', 'teardown': 'function wrap(){}' }) );
/*--------------------------------------------------------------------------*/
suites.push( Benchmark.Suite('`_.zip`') .add(buildName, { 'fn': 'lodash.zip.apply(lodash, unzipped)', 'teardown': 'function zip(){}' }) .add(otherName, { 'fn': '_.zip.apply(_, unzipped)', 'teardown': 'function zip(){}' }) );
/*--------------------------------------------------------------------------*/
if (Benchmark.platform + '') { log(Benchmark.platform); } // Expose `run` to be called later when executing in a browser. if (document) { root.run = run; } else { run(); }}.call(this));