How to use buildName method in argos

Best JavaScript code snippet using argos

perf.js

Source:perf.js Github

copy

Full Screen

1;(function() {2 /** Used to access the Firebug Lite panel (set by `run`). */3 var fbPanel;4 /** Used as a safe reference for `undefined` in pre ES5 environments. */5 var undefined;6 /** Used as a reference to the global object. */7 var root = typeof global == 'object' && global || this;8 /** Method and object shortcuts. */9 var phantom = root.phantom,10 amd = root.define && define.amd,11 argv = root.process && process.argv,12 document = !phantom && root.document,13 noop = function() {},14 params = root.arguments,15 system = root.system;16 /** Add `console.log()` support for Rhino and RingoJS. */17 var console = root.console || (root.console = { 'log': root.print });18 /** The file path of the lodash file to test. */19 var filePath = (function() {20 var min = 0,21 result = [];22 if (phantom) {23 result = params = phantom.args;24 } else if (system) {25 min = 1;26 result = params = system.args;27 } else if (argv) {28 min = 2;29 result = params = argv;30 } else if (params) {31 result = params;32 }33 var last = result[result.length - 1];34 result = (result.length > min && !/perf(?:\.js)?$/.test(last)) ? last : '../lodash.js';35 if (!amd) {36 try {37 result = require('fs').realpathSync(result);38 } catch (e) {}39 try {40 result = require.resolve(result);41 } catch (e) {}42 }43 return result;44 }());45 /** Used to match path separators. */46 var rePathSeparator = /[\/\\]/;47 /** Used to detect primitive types. */48 var rePrimitive = /^(?:boolean|number|string|undefined)$/;49 /** Used to match RegExp special characters. */50 var reSpecialChars = /[.*+?^=!:${}()|[\]\/\\]/g;51 /** The `ui` object. */52 var ui = root.ui || (root.ui = {53 'buildPath': basename(filePath, '.js'),54 'otherPath': 'underscore'55 });56 /** The lodash build basename. */57 var buildName = root.buildName = basename(ui.buildPath, '.js');58 /** The other library basename. */59 var otherName = root.otherName = (function() {60 var result = basename(ui.otherPath, '.js');61 return result + (result == buildName ? ' (2)' : '');62 }());63 /** Used to score performance. */64 var score = { 'a': [], 'b': [] };65 /** Used to queue benchmark suites. */66 var suites = [];67 /** Use a single "load" function. */68 var load = (typeof require == 'function' && !amd)69 ? require70 : noop;71 /** Load lodash. */72 var lodash = root.lodash || (root.lodash = (73 lodash = load(filePath) || root._,74 lodash = lodash._ || lodash,75 (lodash.runInContext ? lodash.runInContext(root) : lodash),76 lodash.noConflict()77 ));78 /** Load Underscore. */79 var _ = root.underscore || (root.underscore = (80 _ = load('../vendor/underscore/underscore.js') || root._,81 _._ || _82 ));83 /** Load Benchmark.js. */84 var Benchmark = root.Benchmark || (root.Benchmark = (85 Benchmark = load('../node_modules/benchmark/benchmark.js') || root.Benchmark,86 Benchmark = Benchmark.Benchmark || Benchmark,87 Benchmark.runInContext(lodash.extend({}, root, { '_': lodash }))88 ));89 /*--------------------------------------------------------------------------*/90 /**91 * Gets the basename of the given `filePath`. If the file `extension` is passed,92 * it will be removed from the basename.93 *94 * @private95 * @param {string} path The file path to inspect.96 * @param {string} extension The extension to remove.97 * @returns {string} Returns the basename.98 */99 function basename(filePath, extension) {100 var result = (filePath || '').split(rePathSeparator).pop();101 return (arguments.length < 2)102 ? result103 : result.replace(RegExp(extension.replace(reSpecialChars, '\\$&') + '$'), '');104 }105 /**106 * Computes the geometric mean (log-average) of an array of values.107 * See http://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms.108 *109 * @private110 * @param {Array} array The array of values.111 * @returns {number} The geometric mean.112 */113 function getGeometricMean(array) {114 return Math.pow(Math.E, lodash.reduce(array, function(sum, x) {115 return sum + Math.log(x);116 }, 0) / array.length) || 0;117 }118 /**119 * Gets the Hz, i.e. operations per second, of `bench` adjusted for the120 * margin of error.121 *122 * @private123 * @param {Object} bench The benchmark object.124 * @returns {number} Returns the adjusted Hz.125 */126 function getHz(bench) {127 var result = 1 / (bench.stats.mean + bench.stats.moe);128 return isFinite(result) ? result : 0;129 }130 /**131 * Host objects can return type values that are different from their actual132 * data type. The objects we are concerned with usually return non-primitive133 * types of "object", "function", or "unknown".134 *135 * @private136 * @param {*} object The owner of the property.137 * @param {string} property The property to check.138 * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.139 */140 function isHostType(object, property) {141 if (object == null) {142 return false;143 }144 var type = typeof object[property];145 return !rePrimitive.test(type) && (type != 'object' || !!object[property]);146 }147 /**148 * Logs text to the console.149 *150 * @private151 * @param {string} text The text to log.152 */153 function log(text) {154 console.log(text + '');155 if (fbPanel) {156 // Scroll the Firebug Lite panel down.157 fbPanel.scrollTop = fbPanel.scrollHeight;158 }159 }160 /**161 * Runs all benchmark suites.162 *163 * @private (@public in the browser)164 */165 function run() {166 fbPanel = (fbPanel = root.document && document.getElementById('FirebugUI')) &&167 (fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&168 fbPanel.getElementById('fbPanel1');169 log('\nSit back and relax, this may take a while.');170 suites[0].run({ 'async': true });171 }172 /*--------------------------------------------------------------------------*/173 lodash.extend(Benchmark.Suite.options, {174 'onStart': function() {175 log('\n' + this.name + ':');176 },177 'onCycle': function(event) {178 log(event.target);179 },180 'onComplete': function() {181 for (var index = 0, length = this.length; index < length; index++) {182 var bench = this[index];183 if (bench.error) {184 var errored = true;185 }186 }187 if (errored) {188 log('There was a problem, skipping...');189 }190 else {191 var formatNumber = Benchmark.formatNumber,192 fastest = this.filter('fastest'),193 fastestHz = getHz(fastest[0]),194 slowest = this.filter('slowest'),195 slowestHz = getHz(slowest[0]),196 aHz = getHz(this[0]),197 bHz = getHz(this[1]);198 if (fastest.length > 1) {199 log('It\'s too close to call.');200 aHz = bHz = slowestHz;201 }202 else {203 var percent = ((fastestHz / slowestHz) - 1) * 100;204 log(205 fastest[0].name + ' is ' +206 formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) +207 '% faster.'208 );209 }210 // Add score adjusted for margin of error.211 score.a.push(aHz);212 score.b.push(bHz);213 }214 // Remove current suite from queue.215 suites.shift();216 if (suites.length) {217 // Run next suite.218 suites[0].run({ 'async': true });219 }220 else {221 var aMeanHz = getGeometricMean(score.a),222 bMeanHz = getGeometricMean(score.b),223 fastestMeanHz = Math.max(aMeanHz, bMeanHz),224 slowestMeanHz = Math.min(aMeanHz, bMeanHz),225 xFaster = fastestMeanHz / slowestMeanHz,226 percentFaster = formatNumber(Math.round((xFaster - 1) * 100)),227 message = 'is ' + percentFaster + '% ' + (xFaster == 1 ? '' : '(' + formatNumber(xFaster.toFixed(2)) + 'x) ') + 'faster than';228 // Report results.229 if (aMeanHz >= bMeanHz) {230 log('\n' + buildName + ' ' + message + ' ' + otherName + '.');231 } else {232 log('\n' + otherName + ' ' + message + ' ' + buildName + '.');233 }234 }235 }236 });237 /*--------------------------------------------------------------------------*/238 lodash.extend(Benchmark.options, {239 'async': true,240 'setup': '\241 var _ = global.underscore,\242 lodash = global.lodash,\243 belt = this.name == buildName ? lodash : _;\244 \245 var date = new Date,\246 limit = 50,\247 regexp = /x/,\248 object = {},\249 objects = Array(limit),\250 numbers = Array(limit),\251 fourNumbers = [5, 25, 10, 30],\252 nestedNumbers = [1, [2], [3, [[4]]]],\253 nestedObjects = [{}, [{}], [{}, [[{}]]]],\254 twoNumbers = [12, 23];\255 \256 for (var index = 0; index < limit; index++) {\257 numbers[index] = index;\258 object["key" + index] = index;\259 objects[index] = { "num": index };\260 }\261 var strNumbers = numbers + "";\262 \263 if (typeof assign != "undefined") {\264 var _assign = _.assign || _.extend,\265 lodashAssign = lodash.assign;\266 }\267 if (typeof bind != "undefined") {\268 var thisArg = { "name": "fred" };\269 \270 var func = function(greeting, punctuation) {\271 return (greeting || "hi") + " " + this.name + (punctuation || ".");\272 };\273 \274 var _boundNormal = _.bind(func, thisArg),\275 _boundMultiple = _boundNormal,\276 _boundPartial = _.bind(func, thisArg, "hi");\277 \278 var lodashBoundNormal = lodash.bind(func, thisArg),\279 lodashBoundMultiple = lodashBoundNormal,\280 lodashBoundPartial = lodash.bind(func, thisArg, "hi");\281 \282 for (index = 0; index < 10; index++) {\283 _boundMultiple = _.bind(_boundMultiple, { "name": "fred" + index });\284 lodashBoundMultiple = lodash.bind(lodashBoundMultiple, { "name": "fred" + index });\285 }\286 }\287 if (typeof bindAll != "undefined") {\288 var bindAllCount = -1,\289 bindAllObjects = Array(this.count);\290 \291 var funcNames = belt.reject(belt.functions(belt).slice(0, 40), function(funcName) {\292 return /^_/.test(funcName);\293 });\294 \295 // Potentially expensive.\n\296 for (index = 0; index < this.count; index++) {\297 bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\298 object[funcName] = belt[funcName];\299 return object;\300 }, {});\301 }\302 }\303 if (typeof chaining != "undefined") {\304 var even = function(v) { return v % 2 == 0; },\305 square = function(v) { return v * v; };\306 \307 var largeArray = belt.range(10000),\308 _chaining = _(largeArray).chain(),\309 lodashChaining = lodash(largeArray).chain();\310 }\311 if (typeof compact != "undefined") {\312 var uncompacted = numbers.slice();\313 uncompacted[2] = false;\314 uncompacted[6] = null;\315 uncompacted[18] = "";\316 }\317 if (typeof flowRight != "undefined") {\318 var compAddOne = function(n) { return n + 1; },\319 compAddTwo = function(n) { return n + 2; },\320 compAddThree = function(n) { return n + 3; };\321 \322 var _composed = _.flowRight && _.flowRight(compAddThree, compAddTwo, compAddOne),\323 lodashComposed = lodash.flowRight && lodash.flowRight(compAddThree, compAddTwo, compAddOne);\324 }\325 if (typeof countBy != "undefined" || typeof omit != "undefined") {\326 var wordToNumber = {\327 "one": 1,\328 "two": 2,\329 "three": 3,\330 "four": 4,\331 "five": 5,\332 "six": 6,\333 "seven": 7,\334 "eight": 8,\335 "nine": 9,\336 "ten": 10,\337 "eleven": 11,\338 "twelve": 12,\339 "thirteen": 13,\340 "fourteen": 14,\341 "fifteen": 15,\342 "sixteen": 16,\343 "seventeen": 17,\344 "eighteen": 18,\345 "nineteen": 19,\346 "twenty": 20,\347 "twenty-one": 21,\348 "twenty-two": 22,\349 "twenty-three": 23,\350 "twenty-four": 24,\351 "twenty-five": 25,\352 "twenty-six": 26,\353 "twenty-seven": 27,\354 "twenty-eight": 28,\355 "twenty-nine": 29,\356 "thirty": 30,\357 "thirty-one": 31,\358 "thirty-two": 32,\359 "thirty-three": 33,\360 "thirty-four": 34,\361 "thirty-five": 35,\362 "thirty-six": 36,\363 "thirty-seven": 37,\364 "thirty-eight": 38,\365 "thirty-nine": 39,\366 "forty": 40\367 };\368 \369 var words = belt.keys(wordToNumber).slice(0, limit);\370 }\371 if (typeof flatten != "undefined") {\372 var _flattenDeep = _.flatten([[1]])[0] !== 1,\373 lodashFlattenDeep = lodash.flatten([[1]])[0] !== 1;\374 }\375 if (typeof isEqual != "undefined") {\376 var objectOfPrimitives = {\377 "boolean": true,\378 "number": 1,\379 "string": "a"\380 };\381 \382 var objectOfObjects = {\383 "boolean": new Boolean(true),\384 "number": new Number(1),\385 "string": new String("a")\386 };\387 \388 var objectOfObjects2 = {\389 "boolean": new Boolean(true),\390 "number": new Number(1),\391 "string": new String("A")\392 };\393 \394 var object2 = {},\395 object3 = {},\396 objects2 = Array(limit),\397 objects3 = Array(limit),\398 numbers2 = Array(limit),\399 numbers3 = Array(limit),\400 nestedNumbers2 = [1, [2], [3, [[4]]]],\401 nestedNumbers3 = [1, [2], [3, [[6]]]];\402 \403 for (index = 0; index < limit; index++) {\404 object2["key" + index] = index;\405 object3["key" + index] = index;\406 objects2[index] = { "num": index };\407 objects3[index] = { "num": index };\408 numbers2[index] = index;\409 numbers3[index] = index;\410 }\411 object3["key" + (limit - 1)] = -1;\412 objects3[limit - 1].num = -1;\413 numbers3[limit - 1] = -1;\414 }\415 if (typeof matches != "undefined") {\416 var source = { "num": 9 };\417 \418 var _matcher = (_.matches || _.noop)(source),\419 lodashMatcher = (lodash.matches || lodash.noop)(source);\420 }\421 if (typeof multiArrays != "undefined") {\422 var twentyValues = belt.shuffle(belt.range(20)),\423 fortyValues = belt.shuffle(belt.range(40)),\424 hundredSortedValues = belt.range(100),\425 hundredValues = belt.shuffle(hundredSortedValues),\426 hundredValues2 = belt.shuffle(hundredValues),\427 hundredTwentyValues = belt.shuffle(belt.range(120)),\428 hundredTwentyValues2 = belt.shuffle(hundredTwentyValues),\429 twoHundredValues = belt.shuffle(belt.range(200)),\430 twoHundredValues2 = belt.shuffle(twoHundredValues);\431 }\432 if (typeof partial != "undefined") {\433 var func = function(greeting, punctuation) {\434 return greeting + " fred" + (punctuation || ".");\435 };\436 \437 var _partial = _.partial(func, "hi"),\438 lodashPartial = lodash.partial(func, "hi");\439 }\440 if (typeof template != "undefined") {\441 var tplData = {\442 "header1": "Header1",\443 "header2": "Header2",\444 "header3": "Header3",\445 "header4": "Header4",\446 "header5": "Header5",\447 "header6": "Header6",\448 "list": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]\449 };\450 \451 var tpl =\452 "<div>" +\453 "<h1 class=\'header1\'><%= header1 %></h1>" +\454 "<h2 class=\'header2\'><%= header2 %></h2>" +\455 "<h3 class=\'header3\'><%= header3 %></h3>" +\456 "<h4 class=\'header4\'><%= header4 %></h4>" +\457 "<h5 class=\'header5\'><%= header5 %></h5>" +\458 "<h6 class=\'header6\'><%= header6 %></h6>" +\459 "<ul class=\'list\'>" +\460 "<% for (var index = 0, length = list.length; index < length; index++) { %>" +\461 "<li class=\'item\'><%= list[index] %></li>" +\462 "<% } %>" +\463 "</ul>" +\464 "</div>";\465 \466 var tplVerbose =\467 "<div>" +\468 "<h1 class=\'header1\'><%= data.header1 %></h1>" +\469 "<h2 class=\'header2\'><%= data.header2 %></h2>" +\470 "<h3 class=\'header3\'><%= data.header3 %></h3>" +\471 "<h4 class=\'header4\'><%= data.header4 %></h4>" +\472 "<h5 class=\'header5\'><%= data.header5 %></h5>" +\473 "<h6 class=\'header6\'><%= data.header6 %></h6>" +\474 "<ul class=\'list\'>" +\475 "<% for (var index = 0, length = data.list.length; index < length; index++) { %>" +\476 "<li class=\'item\'><%= data.list[index] %></li>" +\477 "<% } %>" +\478 "</ul>" +\479 "</div>";\480 \481 var settingsObject = { "variable": "data" };\482 \483 var _tpl = _.template(tpl),\484 _tplVerbose = _.template(tplVerbose, null, settingsObject);\485 \486 var lodashTpl = lodash.template(tpl),\487 lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject);\488 }\489 if (typeof wrap != "undefined") {\490 var add = function(a, b) {\491 return a + b;\492 };\493 \494 var average = function(func, a, b) {\495 return (func(a, b) / 2).toFixed(2);\496 };\497 \498 var _wrapped = _.wrap(add, average);\499 lodashWrapped = lodash.wrap(add, average);\500 }\501 if (typeof zip != "undefined") {\502 var unzipped = [["a", "b", "c"], [1, 2, 3], [true, false, true]];\503 }'504 });505 /*--------------------------------------------------------------------------*/506 suites.push(507 Benchmark.Suite('`_(...).map(...).filter(...).take(...).value()`')508 .add(buildName, {509 'fn': 'lodashChaining.map(square).filter(even).take(100).value()',510 'teardown': 'function chaining(){}'511 })512 .add(otherName, {513 'fn': '_chaining.map(square).filter(even).take(100).value()',514 'teardown': 'function chaining(){}'515 })516 );517 /*--------------------------------------------------------------------------*/518 suites.push(519 Benchmark.Suite('`_.assign`')520 .add(buildName, {521 'fn': 'lodashAssign({}, { "a": 1, "b": 2, "c": 3 })',522 'teardown': 'function assign(){}'523 })524 .add(otherName, {525 'fn': '_assign({}, { "a": 1, "b": 2, "c": 3 })',526 'teardown': 'function assign(){}'527 })528 );529 suites.push(530 Benchmark.Suite('`_.assign` with multiple sources')531 .add(buildName, {532 'fn': 'lodashAssign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })',533 'teardown': 'function assign(){}'534 })535 .add(otherName, {536 'fn': '_assign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })',537 'teardown': 'function assign(){}'538 })539 );540 /*--------------------------------------------------------------------------*/541 suites.push(542 Benchmark.Suite('`_.bind` (slow path)')543 .add(buildName, {544 'fn': 'lodash.bind(function() { return this.name; }, { "name": "fred" })',545 'teardown': 'function bind(){}'546 })547 .add(otherName, {548 'fn': '_.bind(function() { return this.name; }, { "name": "fred" })',549 'teardown': 'function bind(){}'550 })551 );552 suites.push(553 Benchmark.Suite('bound call with arguments')554 .add(buildName, {555 'fn': 'lodashBoundNormal("hi", "!")',556 'teardown': 'function bind(){}'557 })558 .add(otherName, {559 'fn': '_boundNormal("hi", "!")',560 'teardown': 'function bind(){}'561 })562 );563 suites.push(564 Benchmark.Suite('bound and partially applied call with arguments')565 .add(buildName, {566 'fn': 'lodashBoundPartial("!")',567 'teardown': 'function bind(){}'568 })569 .add(otherName, {570 'fn': '_boundPartial("!")',571 'teardown': 'function bind(){}'572 })573 );574 suites.push(575 Benchmark.Suite('bound multiple times')576 .add(buildName, {577 'fn': 'lodashBoundMultiple()',578 'teardown': 'function bind(){}'579 })580 .add(otherName, {581 'fn': '_boundMultiple()',582 'teardown': 'function bind(){}'583 })584 );585 /*--------------------------------------------------------------------------*/586 suites.push(587 Benchmark.Suite('`_.bindAll`')588 .add(buildName, {589 'fn': 'lodash.bindAll(bindAllObjects[++bindAllCount], funcNames)',590 'teardown': 'function bindAll(){}'591 })592 .add(otherName, {593 'fn': '_.bindAll(bindAllObjects[++bindAllCount], funcNames)',594 'teardown': 'function bindAll(){}'595 })596 );597 /*--------------------------------------------------------------------------*/598 suites.push(599 Benchmark.Suite('`_.clone` with an array')600 .add(buildName, '\601 lodash.clone(numbers)'602 )603 .add(otherName, '\604 _.clone(numbers)'605 )606 );607 suites.push(608 Benchmark.Suite('`_.clone` with an object')609 .add(buildName, '\610 lodash.clone(object)'611 )612 .add(otherName, '\613 _.clone(object)'614 )615 );616 /*--------------------------------------------------------------------------*/617 suites.push(618 Benchmark.Suite('`_.compact`')619 .add(buildName, {620 'fn': 'lodash.compact(uncompacted)',621 'teardown': 'function compact(){}'622 })623 .add(otherName, {624 'fn': '_.compact(uncompacted)',625 'teardown': 'function compact(){}'626 })627 );628 /*--------------------------------------------------------------------------*/629 suites.push(630 Benchmark.Suite('`_.countBy` with `callback` iterating an array')631 .add(buildName, '\632 lodash.countBy(numbers, function(num) { return num >> 1; })'633 )634 .add(otherName, '\635 _.countBy(numbers, function(num) { return num >> 1; })'636 )637 );638 suites.push(639 Benchmark.Suite('`_.countBy` with `property` name iterating an array')640 .add(buildName, {641 'fn': 'lodash.countBy(words, "length")',642 'teardown': 'function countBy(){}'643 })644 .add(otherName, {645 'fn': '_.countBy(words, "length")',646 'teardown': 'function countBy(){}'647 })648 );649 suites.push(650 Benchmark.Suite('`_.countBy` with `callback` iterating an object')651 .add(buildName, {652 'fn': 'lodash.countBy(wordToNumber, function(num) { return num >> 1; })',653 'teardown': 'function countBy(){}'654 })655 .add(otherName, {656 'fn': '_.countBy(wordToNumber, function(num) { return num >> 1; })',657 'teardown': 'function countBy(){}'658 })659 );660 /*--------------------------------------------------------------------------*/661 suites.push(662 Benchmark.Suite('`_.defaults`')663 .add(buildName, '\664 lodash.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'665 )666 .add(otherName, '\667 _.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'668 )669 );670 /*--------------------------------------------------------------------------*/671 suites.push(672 Benchmark.Suite('`_.difference`')673 .add(buildName, '\674 lodash.difference(numbers, twoNumbers, fourNumbers)'675 )676 .add(otherName, '\677 _.difference(numbers, twoNumbers, fourNumbers)'678 )679 );680 suites.push(681 Benchmark.Suite('`_.difference` iterating 20 and 40 elements')682 .add(buildName, {683 'fn': 'lodash.difference(twentyValues, fortyValues)',684 'teardown': 'function multiArrays(){}'685 })686 .add(otherName, {687 'fn': '_.difference(twentyValues, fortyValues)',688 'teardown': 'function multiArrays(){}'689 })690 );691 suites.push(692 Benchmark.Suite('`_.difference` iterating 200 elements')693 .add(buildName, {694 'fn': 'lodash.difference(twoHundredValues, twoHundredValues2)',695 'teardown': 'function multiArrays(){}'696 })697 .add(otherName, {698 'fn': '_.difference(twoHundredValues, twoHundredValues2)',699 'teardown': 'function multiArrays(){}'700 })701 );702 /*--------------------------------------------------------------------------*/703 suites.push(704 Benchmark.Suite('`_.each` iterating an array')705 .add(buildName, '\706 var result = [];\707 lodash.each(numbers, function(num) {\708 result.push(num * 2);\709 })'710 )711 .add(otherName, '\712 var result = [];\713 _.each(numbers, function(num) {\714 result.push(num * 2);\715 })'716 )717 );718 suites.push(719 Benchmark.Suite('`_.each` iterating an object')720 .add(buildName, '\721 var result = [];\722 lodash.each(object, function(num) {\723 result.push(num * 2);\724 })'725 )726 .add(otherName, '\727 var result = [];\728 _.each(object, function(num) {\729 result.push(num * 2);\730 })'731 )732 );733 /*--------------------------------------------------------------------------*/734 suites.push(735 Benchmark.Suite('`_.every` iterating an array')736 .add(buildName, '\737 lodash.every(numbers, function(num) {\738 return num < limit;\739 })'740 )741 .add(otherName, '\742 _.every(numbers, function(num) {\743 return num < limit;\744 })'745 )746 );747 suites.push(748 Benchmark.Suite('`_.every` iterating an object')749 .add(buildName, '\750 lodash.every(object, function(num) {\751 return num < limit;\752 })'753 )754 .add(otherName, '\755 _.every(object, function(num) {\756 return num < limit;\757 })'758 )759 );760 /*--------------------------------------------------------------------------*/761 suites.push(762 Benchmark.Suite('`_.filter` iterating an array')763 .add(buildName, '\764 lodash.filter(numbers, function(num) {\765 return num % 2;\766 })'767 )768 .add(otherName, '\769 _.filter(numbers, function(num) {\770 return num % 2;\771 })'772 )773 );774 suites.push(775 Benchmark.Suite('`_.filter` iterating an object')776 .add(buildName, '\777 lodash.filter(object, function(num) {\778 return num % 2\779 })'780 )781 .add(otherName, '\782 _.filter(object, function(num) {\783 return num % 2\784 })'785 )786 );787 suites.push(788 Benchmark.Suite('`_.filter` with `_.matches` shorthand')789 .add(buildName, {790 'fn': 'lodash.filter(objects, source)',791 'teardown': 'function matches(){}'792 })793 .add(otherName, {794 'fn': '_.filter(objects, source)',795 'teardown': 'function matches(){}'796 })797 );798 suites.push(799 Benchmark.Suite('`_.filter` with `_.matches` predicate')800 .add(buildName, {801 'fn': 'lodash.filter(objects, lodashMatcher)',802 'teardown': 'function matches(){}'803 })804 .add(otherName, {805 'fn': '_.filter(objects, _matcher)',806 'teardown': 'function matches(){}'807 })808 );809 /*--------------------------------------------------------------------------*/810 suites.push(811 Benchmark.Suite('`_.find` iterating an array')812 .add(buildName, '\813 lodash.find(numbers, function(num) {\814 return num === (limit - 1);\815 })'816 )817 .add(otherName, '\818 _.find(numbers, function(num) {\819 return num === (limit - 1);\820 })'821 )822 );823 suites.push(824 Benchmark.Suite('`_.find` iterating an object')825 .add(buildName, '\826 lodash.find(object, function(value, key) {\827 return /\D9$/.test(key);\828 })'829 )830 .add(otherName, '\831 _.find(object, function(value, key) {\832 return /\D9$/.test(key);\833 })'834 )835 );836 // Avoid Underscore induced `OutOfMemoryError` in Rhino and Ringo.837 suites.push(838 Benchmark.Suite('`_.find` with `_.matches` shorthand')839 .add(buildName, {840 'fn': 'lodash.find(objects, source)',841 'teardown': 'function matches(){}'842 })843 .add(otherName, {844 'fn': '_.find(objects, source)',845 'teardown': 'function matches(){}'846 })847 );848 /*--------------------------------------------------------------------------*/849 suites.push(850 Benchmark.Suite('`_.flatten`')851 .add(buildName, {852 'fn': 'lodash.flatten(nestedNumbers, !lodashFlattenDeep)',853 'teardown': 'function flatten(){}'854 })855 .add(otherName, {856 'fn': '_.flatten(nestedNumbers, !_flattenDeep)',857 'teardown': 'function flatten(){}'858 })859 );860 /*--------------------------------------------------------------------------*/861 suites.push(862 Benchmark.Suite('`_.flattenDeep` nested arrays of numbers')863 .add(buildName, {864 'fn': 'lodash.flattenDeep(nestedNumbers)',865 'teardown': 'function flatten(){}'866 })867 .add(otherName, {868 'fn': '_.flattenDeep(nestedNumbers)',869 'teardown': 'function flatten(){}'870 })871 );872 suites.push(873 Benchmark.Suite('`_.flattenDeep` nest arrays of objects')874 .add(buildName, {875 'fn': 'lodash.flattenDeep(nestedObjects)',876 'teardown': 'function flatten(){}'877 })878 .add(otherName, {879 'fn': '_.flattenDeep(nestedObjects)',880 'teardown': 'function flatten(){}'881 })882 );883 /*--------------------------------------------------------------------------*/884 suites.push(885 Benchmark.Suite('`_.flowRight`')886 .add(buildName, {887 'fn': 'lodash.flowRight(compAddThree, compAddTwo, compAddOne)',888 'teardown': 'function flowRight(){}'889 })890 .add(otherName, {891 'fn': '_.flowRight(compAddThree, compAddTwo, compAddOne)',892 'teardown': 'function flowRight(){}'893 })894 );895 suites.push(896 Benchmark.Suite('composed call')897 .add(buildName, {898 'fn': 'lodashComposed(0)',899 'teardown': 'function flowRight(){}'900 })901 .add(otherName, {902 'fn': '_composed(0)',903 'teardown': 'function flowRight(){}'904 })905 );906 /*--------------------------------------------------------------------------*/907 suites.push(908 Benchmark.Suite('`_.functions`')909 .add(buildName, '\910 lodash.functions(lodash)'911 )912 .add(otherName, '\913 _.functions(lodash)'914 )915 );916 /*--------------------------------------------------------------------------*/917 suites.push(918 Benchmark.Suite('`_.groupBy` with `callback` iterating an array')919 .add(buildName, '\920 lodash.groupBy(numbers, function(num) { return num >> 1; })'921 )922 .add(otherName, '\923 _.groupBy(numbers, function(num) { return num >> 1; })'924 )925 );926 suites.push(927 Benchmark.Suite('`_.groupBy` with `property` name iterating an array')928 .add(buildName, {929 'fn': 'lodash.groupBy(words, "length")',930 'teardown': 'function countBy(){}'931 })932 .add(otherName, {933 'fn': '_.groupBy(words, "length")',934 'teardown': 'function countBy(){}'935 })936 );937 suites.push(938 Benchmark.Suite('`_.groupBy` with `callback` iterating an object')939 .add(buildName, {940 'fn': 'lodash.groupBy(wordToNumber, function(num) { return num >> 1; })',941 'teardown': 'function countBy(){}'942 })943 .add(otherName, {944 'fn': '_.groupBy(wordToNumber, function(num) { return num >> 1; })',945 'teardown': 'function countBy(){}'946 })947 );948 /*--------------------------------------------------------------------------*/949 suites.push(950 Benchmark.Suite('`_.includes` searching an array')951 .add(buildName, '\952 lodash.includes(numbers, limit - 1)'953 )954 .add(otherName, '\955 _.includes(numbers, limit - 1)'956 )957 );958 suites.push(959 Benchmark.Suite('`_.includes` searching an object')960 .add(buildName, '\961 lodash.includes(object, limit - 1)'962 )963 .add(otherName, '\964 _.includes(object, limit - 1)'965 )966 );967 if (lodash.includes('ab', 'ab') && _.includes('ab', 'ab')) {968 suites.push(969 Benchmark.Suite('`_.includes` searching a string')970 .add(buildName, '\971 lodash.includes(strNumbers, "," + (limit - 1))'972 )973 .add(otherName, '\974 _.includes(strNumbers, "," + (limit - 1))'975 )976 );977 }978 /*--------------------------------------------------------------------------*/979 suites.push(980 Benchmark.Suite('`_.indexOf`')981 .add(buildName, {982 'fn': 'lodash.indexOf(hundredSortedValues, 99)',983 'teardown': 'function multiArrays(){}'984 })985 .add(otherName, {986 'fn': '_.indexOf(hundredSortedValues, 99)',987 'teardown': 'function multiArrays(){}'988 })989 );990 /*--------------------------------------------------------------------------*/991 suites.push(992 Benchmark.Suite('`_.intersection`')993 .add(buildName, '\994 lodash.intersection(numbers, twoNumbers, fourNumbers)'995 )996 .add(otherName, '\997 _.intersection(numbers, twoNumbers, fourNumbers)'998 )999 );1000 suites.push(1001 Benchmark.Suite('`_.intersection` iterating 120 elements')1002 .add(buildName, {1003 'fn': 'lodash.intersection(hundredTwentyValues, hundredTwentyValues2)',1004 'teardown': 'function multiArrays(){}'1005 })1006 .add(otherName, {1007 'fn': '_.intersection(hundredTwentyValues, hundredTwentyValues2)',1008 'teardown': 'function multiArrays(){}'1009 })1010 );1011 /*--------------------------------------------------------------------------*/1012 suites.push(1013 Benchmark.Suite('`_.invert`')1014 .add(buildName, '\1015 lodash.invert(object)'1016 )1017 .add(otherName, '\1018 _.invert(object)'1019 )1020 );1021 /*--------------------------------------------------------------------------*/1022 suites.push(1023 Benchmark.Suite('`_.invokeMap` iterating an array')1024 .add(buildName, '\1025 lodash.invokeMap(numbers, "toFixed")'1026 )1027 .add(otherName, '\1028 _.invokeMap(numbers, "toFixed")'1029 )1030 );1031 suites.push(1032 Benchmark.Suite('`_.invokeMap` with arguments iterating an array')1033 .add(buildName, '\1034 lodash.invokeMap(numbers, "toFixed", 1)'1035 )1036 .add(otherName, '\1037 _.invokeMap(numbers, "toFixed", 1)'1038 )1039 );1040 suites.push(1041 Benchmark.Suite('`_.invokeMap` with a function for `path` iterating an array')1042 .add(buildName, '\1043 lodash.invokeMap(numbers, Number.prototype.toFixed, 1)'1044 )1045 .add(otherName, '\1046 _.invokeMap(numbers, Number.prototype.toFixed, 1)'1047 )1048 );1049 suites.push(1050 Benchmark.Suite('`_.invokeMap` iterating an object')1051 .add(buildName, '\1052 lodash.invokeMap(object, "toFixed", 1)'1053 )1054 .add(otherName, '\1055 _.invokeMap(object, "toFixed", 1)'1056 )1057 );1058 /*--------------------------------------------------------------------------*/1059 suites.push(1060 Benchmark.Suite('`_.isEqual` comparing primitives')1061 .add(buildName, {1062 'fn': '\1063 lodash.isEqual(1, "1");\1064 lodash.isEqual(1, 1)',1065 'teardown': 'function isEqual(){}'1066 })1067 .add(otherName, {1068 'fn': '\1069 _.isEqual(1, "1");\1070 _.isEqual(1, 1);',1071 'teardown': 'function isEqual(){}'1072 })1073 );1074 suites.push(1075 Benchmark.Suite('`_.isEqual` comparing primitives and their object counterparts (edge case)')1076 .add(buildName, {1077 'fn': '\1078 lodash.isEqual(objectOfPrimitives, objectOfObjects);\1079 lodash.isEqual(objectOfPrimitives, objectOfObjects2)',1080 'teardown': 'function isEqual(){}'1081 })1082 .add(otherName, {1083 'fn': '\1084 _.isEqual(objectOfPrimitives, objectOfObjects);\1085 _.isEqual(objectOfPrimitives, objectOfObjects2)',1086 'teardown': 'function isEqual(){}'1087 })1088 );1089 suites.push(1090 Benchmark.Suite('`_.isEqual` comparing arrays')1091 .add(buildName, {1092 'fn': '\1093 lodash.isEqual(numbers, numbers2);\1094 lodash.isEqual(numbers2, numbers3)',1095 'teardown': 'function isEqual(){}'1096 })1097 .add(otherName, {1098 'fn': '\1099 _.isEqual(numbers, numbers2);\1100 _.isEqual(numbers2, numbers3)',1101 'teardown': 'function isEqual(){}'1102 })1103 );1104 suites.push(1105 Benchmark.Suite('`_.isEqual` comparing nested arrays')1106 .add(buildName, {1107 'fn': '\1108 lodash.isEqual(nestedNumbers, nestedNumbers2);\1109 lodash.isEqual(nestedNumbers2, nestedNumbers3)',1110 'teardown': 'function isEqual(){}'1111 })1112 .add(otherName, {1113 'fn': '\1114 _.isEqual(nestedNumbers, nestedNumbers2);\1115 _.isEqual(nestedNumbers2, nestedNumbers3)',1116 'teardown': 'function isEqual(){}'1117 })1118 );1119 suites.push(1120 Benchmark.Suite('`_.isEqual` comparing arrays of objects')1121 .add(buildName, {1122 'fn': '\1123 lodash.isEqual(objects, objects2);\1124 lodash.isEqual(objects2, objects3)',1125 'teardown': 'function isEqual(){}'1126 })1127 .add(otherName, {1128 'fn': '\1129 _.isEqual(objects, objects2);\1130 _.isEqual(objects2, objects3)',1131 'teardown': 'function isEqual(){}'1132 })1133 );1134 suites.push(1135 Benchmark.Suite('`_.isEqual` comparing objects')1136 .add(buildName, {1137 'fn': '\1138 lodash.isEqual(object, object2);\1139 lodash.isEqual(object2, object3)',1140 'teardown': 'function isEqual(){}'1141 })1142 .add(otherName, {1143 'fn': '\1144 _.isEqual(object, object2);\1145 _.isEqual(object2, object3)',1146 'teardown': 'function isEqual(){}'1147 })1148 );1149 /*--------------------------------------------------------------------------*/1150 suites.push(1151 Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isObject`, `_.isRegExp`')1152 .add(buildName, '\1153 lodash.isArguments(arguments);\1154 lodash.isArguments(object);\1155 lodash.isDate(date);\1156 lodash.isDate(object);\1157 lodash.isFunction(lodash);\1158 lodash.isFunction(object);\1159 lodash.isNumber(1);\1160 lodash.isNumber(object);\1161 lodash.isObject(object);\1162 lodash.isObject(1);\1163 lodash.isRegExp(regexp);\1164 lodash.isRegExp(object)'1165 )1166 .add(otherName, '\1167 _.isArguments(arguments);\1168 _.isArguments(object);\1169 _.isDate(date);\1170 _.isDate(object);\1171 _.isFunction(_);\1172 _.isFunction(object);\1173 _.isNumber(1);\1174 _.isNumber(object);\1175 _.isObject(object);\1176 _.isObject(1);\1177 _.isRegExp(regexp);\1178 _.isRegExp(object)'1179 )1180 );1181 /*--------------------------------------------------------------------------*/1182 suites.push(1183 Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)')1184 .add(buildName, '\1185 lodash.keys(object)'1186 )1187 .add(otherName, '\1188 _.keys(object)'1189 )1190 );1191 /*--------------------------------------------------------------------------*/1192 suites.push(1193 Benchmark.Suite('`_.lastIndexOf`')1194 .add(buildName, {1195 'fn': 'lodash.lastIndexOf(hundredSortedValues, 0)',1196 'teardown': 'function multiArrays(){}'1197 })1198 .add(otherName, {1199 'fn': '_.lastIndexOf(hundredSortedValues, 0)',1200 'teardown': 'function multiArrays(){}'1201 })1202 );1203 /*--------------------------------------------------------------------------*/1204 suites.push(1205 Benchmark.Suite('`_.map` iterating an array')1206 .add(buildName, '\1207 lodash.map(objects, function(value) {\1208 return value.num;\1209 })'1210 )1211 .add(otherName, '\1212 _.map(objects, function(value) {\1213 return value.num;\1214 })'1215 )1216 );1217 suites.push(1218 Benchmark.Suite('`_.map` iterating an object')1219 .add(buildName, '\1220 lodash.map(object, function(value) {\1221 return value;\1222 })'1223 )1224 .add(otherName, '\1225 _.map(object, function(value) {\1226 return value;\1227 })'1228 )1229 );1230 suites.push(1231 Benchmark.Suite('`_.map` with `_.property` shorthand')1232 .add(buildName, '\1233 lodash.map(objects, "num")'1234 )1235 .add(otherName, '\1236 _.map(objects, "num")'1237 )1238 );1239 /*--------------------------------------------------------------------------*/1240 suites.push(1241 Benchmark.Suite('`_.max`')1242 .add(buildName, '\1243 lodash.max(numbers)'1244 )1245 .add(otherName, '\1246 _.max(numbers)'1247 )1248 );1249 /*--------------------------------------------------------------------------*/1250 suites.push(1251 Benchmark.Suite('`_.min`')1252 .add(buildName, '\1253 lodash.min(numbers)'1254 )1255 .add(otherName, '\1256 _.min(numbers)'1257 )1258 );1259 /*--------------------------------------------------------------------------*/1260 suites.push(1261 Benchmark.Suite('`_.omit` iterating 20 properties, omitting 2 keys')1262 .add(buildName, '\1263 lodash.omit(object, "key6", "key13")'1264 )1265 .add(otherName, '\1266 _.omit(object, "key6", "key13")'1267 )1268 );1269 suites.push(1270 Benchmark.Suite('`_.omit` iterating 40 properties, omitting 20 keys')1271 .add(buildName, {1272 'fn': 'lodash.omit(wordToNumber, words)',1273 'teardown': 'function omit(){}'1274 })1275 .add(otherName, {1276 'fn': '_.omit(wordToNumber, words)',1277 'teardown': 'function omit(){}'1278 })1279 );1280 /*--------------------------------------------------------------------------*/1281 suites.push(1282 Benchmark.Suite('`_.partial` (slow path)')1283 .add(buildName, {1284 'fn': 'lodash.partial(function(greeting) { return greeting + " " + this.name; }, "hi")',1285 'teardown': 'function partial(){}'1286 })1287 .add(otherName, {1288 'fn': '_.partial(function(greeting) { return greeting + " " + this.name; }, "hi")',1289 'teardown': 'function partial(){}'1290 })1291 );1292 suites.push(1293 Benchmark.Suite('partially applied call with arguments')1294 .add(buildName, {1295 'fn': 'lodashPartial("!")',1296 'teardown': 'function partial(){}'1297 })1298 .add(otherName, {1299 'fn': '_partial("!")',1300 'teardown': 'function partial(){}'1301 })1302 );1303 /*--------------------------------------------------------------------------*/1304 suites.push(1305 Benchmark.Suite('`_.partition` iterating an array')1306 .add(buildName, '\1307 lodash.partition(numbers, function(num) {\1308 return num % 2;\1309 })'1310 )1311 .add(otherName, '\1312 _.partition(numbers, function(num) {\1313 return num % 2;\1314 })'1315 )1316 );1317 suites.push(1318 Benchmark.Suite('`_.partition` iterating an object')1319 .add(buildName, '\1320 lodash.partition(object, function(num) {\1321 return num % 2;\1322 })'1323 )1324 .add(otherName, '\1325 _.partition(object, function(num) {\1326 return num % 2;\1327 })'1328 )1329 );1330 /*--------------------------------------------------------------------------*/1331 suites.push(1332 Benchmark.Suite('`_.pick`')1333 .add(buildName, '\1334 lodash.pick(object, "key6", "key13")'1335 )1336 .add(otherName, '\1337 _.pick(object, "key6", "key13")'1338 )1339 );1340 /*--------------------------------------------------------------------------*/1341 suites.push(1342 Benchmark.Suite('`_.reduce` iterating an array')1343 .add(buildName, '\1344 lodash.reduce(numbers, function(result, value, index) {\1345 result[index] = value;\1346 return result;\1347 }, {})'1348 )1349 .add(otherName, '\1350 _.reduce(numbers, function(result, value, index) {\1351 result[index] = value;\1352 return result;\1353 }, {})'1354 )1355 );1356 suites.push(1357 Benchmark.Suite('`_.reduce` iterating an object')1358 .add(buildName, '\1359 lodash.reduce(object, function(result, value, key) {\1360 result.push(key, value);\1361 return result;\1362 }, [])'1363 )1364 .add(otherName, '\1365 _.reduce(object, function(result, value, key) {\1366 result.push(key, value);\1367 return result;\1368 }, [])'1369 )1370 );1371 /*--------------------------------------------------------------------------*/1372 suites.push(1373 Benchmark.Suite('`_.reduceRight` iterating an array')1374 .add(buildName, '\1375 lodash.reduceRight(numbers, function(result, value, index) {\1376 result[index] = value;\1377 return result;\1378 }, {})'1379 )1380 .add(otherName, '\1381 _.reduceRight(numbers, function(result, value, index) {\1382 result[index] = value;\1383 return result;\1384 }, {})'1385 )1386 );1387 suites.push(1388 Benchmark.Suite('`_.reduceRight` iterating an object')1389 .add(buildName, '\1390 lodash.reduceRight(object, function(result, value, key) {\1391 result.push(key, value);\1392 return result;\1393 }, [])'1394 )1395 .add(otherName, '\1396 _.reduceRight(object, function(result, value, key) {\1397 result.push(key, value);\1398 return result;\1399 }, [])'1400 )1401 );1402 /*--------------------------------------------------------------------------*/1403 suites.push(1404 Benchmark.Suite('`_.reject` iterating an array')1405 .add(buildName, '\1406 lodash.reject(numbers, function(num) {\1407 return num % 2;\1408 })'1409 )1410 .add(otherName, '\1411 _.reject(numbers, function(num) {\1412 return num % 2;\1413 })'1414 )1415 );1416 suites.push(1417 Benchmark.Suite('`_.reject` iterating an object')1418 .add(buildName, '\1419 lodash.reject(object, function(num) {\1420 return num % 2;\1421 })'1422 )1423 .add(otherName, '\1424 _.reject(object, function(num) {\1425 return num % 2;\1426 })'1427 )1428 );1429 /*--------------------------------------------------------------------------*/1430 suites.push(1431 Benchmark.Suite('`_.sampleSize`')1432 .add(buildName, '\1433 lodash.sampleSize(numbers, limit / 2)'1434 )1435 .add(otherName, '\1436 _.sampleSize(numbers, limit / 2)'1437 )1438 );1439 /*--------------------------------------------------------------------------*/1440 suites.push(1441 Benchmark.Suite('`_.shuffle`')1442 .add(buildName, '\1443 lodash.shuffle(numbers)'1444 )1445 .add(otherName, '\1446 _.shuffle(numbers)'1447 )1448 );1449 /*--------------------------------------------------------------------------*/1450 suites.push(1451 Benchmark.Suite('`_.size` with an object')1452 .add(buildName, '\1453 lodash.size(object)'1454 )1455 .add(otherName, '\1456 _.size(object)'1457 )1458 );1459 /*--------------------------------------------------------------------------*/1460 suites.push(1461 Benchmark.Suite('`_.some` iterating an array')1462 .add(buildName, '\1463 lodash.some(numbers, function(num) {\1464 return num == (limit - 1);\1465 })'1466 )1467 .add(otherName, '\1468 _.some(numbers, function(num) {\1469 return num == (limit - 1);\1470 })'1471 )1472 );1473 suites.push(1474 Benchmark.Suite('`_.some` iterating an object')1475 .add(buildName, '\1476 lodash.some(object, function(num) {\1477 return num == (limit - 1);\1478 })'1479 )1480 .add(otherName, '\1481 _.some(object, function(num) {\1482 return num == (limit - 1);\1483 })'1484 )1485 );1486 /*--------------------------------------------------------------------------*/1487 suites.push(1488 Benchmark.Suite('`_.sortBy` with `callback`')1489 .add(buildName, '\1490 lodash.sortBy(numbers, function(num) { return Math.sin(num); })'1491 )1492 .add(otherName, '\1493 _.sortBy(numbers, function(num) { return Math.sin(num); })'1494 )1495 );1496 suites.push(1497 Benchmark.Suite('`_.sortBy` with `property` name')1498 .add(buildName, {1499 'fn': 'lodash.sortBy(words, "length")',1500 'teardown': 'function countBy(){}'1501 })1502 .add(otherName, {1503 'fn': '_.sortBy(words, "length")',1504 'teardown': 'function countBy(){}'1505 })1506 );1507 /*--------------------------------------------------------------------------*/1508 suites.push(1509 Benchmark.Suite('`_.sortedIndex`')1510 .add(buildName, '\1511 lodash.sortedIndex(numbers, limit)'1512 )1513 .add(otherName, '\1514 _.sortedIndex(numbers, limit)'1515 )1516 );1517 /*--------------------------------------------------------------------------*/1518 suites.push(1519 Benchmark.Suite('`_.sortedIndexBy`')1520 .add(buildName, {1521 'fn': '\1522 lodash.sortedIndexBy(words, "twenty-five", function(value) {\1523 return wordToNumber[value];\1524 })',1525 'teardown': 'function countBy(){}'1526 })1527 .add(otherName, {1528 'fn': '\1529 _.sortedIndexBy(words, "twenty-five", function(value) {\1530 return wordToNumber[value];\1531 })',1532 'teardown': 'function countBy(){}'1533 })1534 );1535 /*--------------------------------------------------------------------------*/1536 suites.push(1537 Benchmark.Suite('`_.sortedIndexOf`')1538 .add(buildName, {1539 'fn': 'lodash.sortedIndexOf(hundredSortedValues, 99)',1540 'teardown': 'function multiArrays(){}'1541 })1542 .add(otherName, {1543 'fn': '_.sortedIndexOf(hundredSortedValues, 99)',1544 'teardown': 'function multiArrays(){}'1545 })1546 );1547 /*--------------------------------------------------------------------------*/1548 suites.push(1549 Benchmark.Suite('`_.sortedLastIndexOf`')1550 .add(buildName, {1551 'fn': 'lodash.sortedLastIndexOf(hundredSortedValues, 0)',1552 'teardown': 'function multiArrays(){}'1553 })1554 .add(otherName, {1555 'fn': '_.sortedLastIndexOf(hundredSortedValues, 0)',1556 'teardown': 'function multiArrays(){}'1557 })1558 );1559 /*--------------------------------------------------------------------------*/1560 suites.push(1561 Benchmark.Suite('`_.sum`')1562 .add(buildName, '\1563 lodash.sum(numbers)'1564 )1565 .add(otherName, '\1566 _.sum(numbers)'1567 )1568 );1569 /*--------------------------------------------------------------------------*/1570 suites.push(1571 Benchmark.Suite('`_.template` (slow path)')1572 .add(buildName, {1573 'fn': 'lodash.template(tpl)(tplData)',1574 'teardown': 'function template(){}'1575 })1576 .add(otherName, {1577 'fn': '_.template(tpl)(tplData)',1578 'teardown': 'function template(){}'1579 })1580 );1581 suites.push(1582 Benchmark.Suite('compiled template')1583 .add(buildName, {1584 'fn': 'lodashTpl(tplData)',1585 'teardown': 'function template(){}'1586 })1587 .add(otherName, {1588 'fn': '_tpl(tplData)',1589 'teardown': 'function template(){}'1590 })1591 );1592 suites.push(1593 Benchmark.Suite('compiled template without a with-statement')1594 .add(buildName, {1595 'fn': 'lodashTplVerbose(tplData)',1596 'teardown': 'function template(){}'1597 })1598 .add(otherName, {1599 'fn': '_tplVerbose(tplData)',1600 'teardown': 'function template(){}'1601 })1602 );1603 /*--------------------------------------------------------------------------*/1604 suites.push(1605 Benchmark.Suite('`_.times`')1606 .add(buildName, '\1607 var result = [];\1608 lodash.times(limit, function(n) { result.push(n); })'1609 )1610 .add(otherName, '\1611 var result = [];\1612 _.times(limit, function(n) { result.push(n); })'1613 )1614 );1615 /*--------------------------------------------------------------------------*/1616 suites.push(1617 Benchmark.Suite('`_.toArray` with an array (edge case)')1618 .add(buildName, '\1619 lodash.toArray(numbers)'1620 )1621 .add(otherName, '\1622 _.toArray(numbers)'1623 )1624 );1625 suites.push(1626 Benchmark.Suite('`_.toArray` with an object')1627 .add(buildName, '\1628 lodash.toArray(object)'1629 )1630 .add(otherName, '\1631 _.toArray(object)'1632 )1633 );1634 /*--------------------------------------------------------------------------*/1635 suites.push(1636 Benchmark.Suite('`_.toPairs`')1637 .add(buildName, '\1638 lodash.toPairs(object)'1639 )1640 .add(otherName, '\1641 _.toPairs(object)'1642 )1643 );1644 /*--------------------------------------------------------------------------*/1645 suites.push(1646 Benchmark.Suite('`_.unescape` string without html entities')1647 .add(buildName, '\1648 lodash.unescape("`&`, `<`, `>`, `\\"`, and `\'`")'1649 )1650 .add(otherName, '\1651 _.unescape("`&`, `<`, `>`, `\\"`, and `\'`")'1652 )1653 );1654 suites.push(1655 Benchmark.Suite('`_.unescape` string with html entities')1656 .add(buildName, '\1657 lodash.unescape("`&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;`")'1658 )1659 .add(otherName, '\1660 _.unescape("`&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;`")'1661 )1662 );1663 /*--------------------------------------------------------------------------*/1664 suites.push(1665 Benchmark.Suite('`_.union`')1666 .add(buildName, '\1667 lodash.union(numbers, twoNumbers, fourNumbers)'1668 )1669 .add(otherName, '\1670 _.union(numbers, twoNumbers, fourNumbers)'1671 )1672 );1673 suites.push(1674 Benchmark.Suite('`_.union` iterating an array of 200 elements')1675 .add(buildName, {1676 'fn': 'lodash.union(hundredValues, hundredValues2)',1677 'teardown': 'function multiArrays(){}'1678 })1679 .add(otherName, {1680 'fn': '_.union(hundredValues, hundredValues2)',1681 'teardown': 'function multiArrays(){}'1682 })1683 );1684 /*--------------------------------------------------------------------------*/1685 suites.push(1686 Benchmark.Suite('`_.uniq`')1687 .add(buildName, '\1688 lodash.uniq(numbers.concat(twoNumbers, fourNumbers))'1689 )1690 .add(otherName, '\1691 _.uniq(numbers.concat(twoNumbers, fourNumbers))'1692 )1693 );1694 suites.push(1695 Benchmark.Suite('`_.uniq` iterating an array of 200 elements')1696 .add(buildName, {1697 'fn': 'lodash.uniq(twoHundredValues)',1698 'teardown': 'function multiArrays(){}'1699 })1700 .add(otherName, {1701 'fn': '_.uniq(twoHundredValues)',1702 'teardown': 'function multiArrays(){}'1703 })1704 );1705 /*--------------------------------------------------------------------------*/1706 suites.push(1707 Benchmark.Suite('`_.uniqBy`')1708 .add(buildName, '\1709 lodash.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\1710 return num % 2;\1711 })'1712 )1713 .add(otherName, '\1714 _.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\1715 return num % 2;\1716 })'1717 )1718 );1719 /*--------------------------------------------------------------------------*/1720 suites.push(1721 Benchmark.Suite('`_.values`')1722 .add(buildName, '\1723 lodash.values(object)'1724 )1725 .add(otherName, '\1726 _.values(object)'1727 )1728 );1729 /*--------------------------------------------------------------------------*/1730 suites.push(1731 Benchmark.Suite('`_.without`')1732 .add(buildName, '\1733 lodash.without(numbers, 9, 12, 14, 15)'1734 )1735 .add(otherName, '\1736 _.without(numbers, 9, 12, 14, 15)'1737 )1738 );1739 /*--------------------------------------------------------------------------*/1740 suites.push(1741 Benchmark.Suite('`_.wrap` result called')1742 .add(buildName, {1743 'fn': 'lodashWrapped(2, 5)',1744 'teardown': 'function wrap(){}'1745 })1746 .add(otherName, {1747 'fn': '_wrapped(2, 5)',1748 'teardown': 'function wrap(){}'1749 })1750 );1751 /*--------------------------------------------------------------------------*/1752 suites.push(1753 Benchmark.Suite('`_.zip`')1754 .add(buildName, {1755 'fn': 'lodash.zip.apply(lodash, unzipped)',1756 'teardown': 'function zip(){}'1757 })1758 .add(otherName, {1759 'fn': '_.zip.apply(_, unzipped)',1760 'teardown': 'function zip(){}'1761 })1762 );1763 /*--------------------------------------------------------------------------*/1764 if (Benchmark.platform + '') {1765 log(Benchmark.platform);1766 }1767 // Expose `run` to be called later when executing in a browser.1768 if (document) {1769 root.run = run;1770 } else {1771 run();1772 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3var buildName = require('argosy').buildName;4var buildName = require('argosy/buildName');5var buildName = require('argosy/buildName.js');6var buildName = require('./argosy/buildName.js');7var buildName = require('./argosy/buildName');8var buildName = require('./argosy/buildName/index.js');9var buildName = require('./argosy/buildName/index');10var buildName = require('./argosy/index.js');11var buildName = require('./argosy/index');12var buildName = require('./argosy');13var buildName = require('argosy/buildName/index.js');14var buildName = require('argosy/buildName/index');15var buildName = require('argosy/buildName');16var buildName = require('argosy/index.js');17var buildName = require('argosy/index');18var buildName = require('argosy');19var buildName = require('argosy/buildName/index.js');20var buildName = require('argosy/buildName/index');21var buildName = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3var name = buildName('John', 'Doe');4console.log(name);5var argosy = require('argosy');6var name = argosy.buildName('John', 'Doe');7console.log(name);8var argosy = require('argosy');9var name = argosy.buildName('John', 'Doe');10console.log(name);11var argosy = require('argosy');12var name = argosy.buildName('John', 'Doe');13console.log(name);14var argosy = require('argosy');15var name = argosy.buildName('John', 'Doe');16console.log(name);17var argosy = require('argosy');18var name = argosy.buildName('John', 'Doe');19console.log(name);20var argosy = require('argosy');21var name = argosy.buildName('John', 'Doe');22console.log(name);23var argosy = require('argosy');24var name = argosy.buildName('John', 'Doe');25console.log(name);26var argosy = require('argosy');27var name = argosy.buildName('John', 'Doe');28console.log(name);29var argosy = require('argosy');30var name = argosy.buildName('John', 'Doe');31console.log(name);

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var argosyPattern = require('argosy-pattern');3var buildName = require('./buildName');4var service = argosy();5service.use(argosyPattern({6}));7service.listen(8000);8var argosyPattern = require('argosy-pattern');9module.exports = argosyPattern({10 buildName: function (firstName, lastName) {11 return firstName + ' ' + lastName;12 }13});14var argosy = require('argosy');15var argosyPattern = require('argosy-pattern');16var buildName = require('./buildName');17var service = argosy();18service.use(argosyPattern({19}));20service.listen(8000);21var argosyPattern = require('argosy-pattern');22module.exports = argosyPattern({23 buildName: function (firstName, lastName) {24 return firstName + ' ' + lastName;25 }26});

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3console.log(buildName('John', 'Doe'));4var argosy = require('argosy');5console.log(argosy.buildName('John', 'Doe'));6var buildName = require('argosy').buildName;7console.log(buildName('John', 'Doe'));8var buildName = require('argosy/buildName');9console.log(buildName('John', 'Doe'));10var buildName = require('argosy').buildName;11console.log(buildName('John', 'Doe'));12var buildName = require('argosy').buildName;13console.log(buildName('John', 'Doe'));14var buildName = require('argosy').buildName;15console.log(buildName('John', 'Doe'));16var buildName = require('argosy').buildName;17console.log(buildName('John', 'Doe'));18var buildName = require('argosy').buildName;19console.log(buildName('John', 'Doe'));20var buildName = require('argosy').buildName;21console.log(buildName('John', 'Doe'));22var buildName = require('argosy').buildName;23console.log(buildName('John', 'Doe'));24var buildName = require('argosy').buildName;

Full Screen

Using AI Code Generation

copy

Full Screen

1var argos = require('argos-sdk');2var name = argos.buildName('John', 'Smith');3var buildName = require('argos-sdk').buildName;4var name = buildName('John', 'Smith');5var buildName = require('argos-sdk/buildName');6var name = buildName('John', 'Smith');7var buildName = require('argos-sdk/buildName.js');8var name = buildName('John', 'Smith');9var buildName = require('argos-sdk/buildName.json');10var name = buildName('John', 'Smith');11var buildName = require('argos-sdk/buildName.txt');12var name = buildName('John', 'Smith');13var buildName = require('argos-sdk/buildName.html');14var name = buildName('John', 'Smith');15var buildName = require('argos-sdk/buildName.css');16var name = buildName('John', 'Smith');17var buildName = require('argos-sdk/buildName.xml');18var name = buildName('John', 'Smith');19var buildName = require('argos-sdk/buildName.md');20var name = buildName('John', 'Smith');21var buildName = require('argos-sdk/buildName.php');22var name = buildName('John', 'Smith');23var buildName = require('argos-sdk/buildName.py');24var name = buildName('John', 'Smith');

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3var myName = buildName('John', 'Doe');4console.log(myName);5exports.buildName = function(firstName, lastName) {6 return firstName + " " + lastName;7};8var argosy = require('argosy');9argosy.addToSum(2);10var sum = argosy.getSum();11console.log(sum);12var sum = 0;13exports.addToSum = function(num) {14 sum += num;15};16exports.getSum = function() {17 return sum;18};19var argosy = require('argosy');20var size = argosy.convertSize(1000000, 'MB');21console.log(size);22exports.convertSize = function(size, unit) {23 var units = ['B', 'KB', 'MB', 'GB', 'TB'];24 var convFactor = 1024;25 var newSize = size;26 for (var i = 0; i < units.length; i++) {27 if (units[i] === unit) {28 break;29 }30 newSize /= convFactor;31 }32 return newSize;33};34var argosy = require('argosy');

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3var name = buildName('John', 'Doe');4var argosy = require('argosy');5var buildName = argosy.buildName;6var name = buildName('John', 'Doe');7var argosy = require('argosy');8var buildName = argosy.buildName;9var name = buildName('John', 'Doe');10var argosy = require('argosy');11var buildName = argosy.buildName;12var name = buildName('John', 'Doe');13var argosy = require('argosy');14var buildName = argosy.buildName;15var name = buildName('John', 'Doe');16var argosy = require('argosy');17var buildName = argosy.buildName;18var name = buildName('John', 'Doe');19var argosy = require('argosy');20var buildName = argosy.buildName;21var name = buildName('John', 'Doe');22var argosy = require('argosy');23var buildName = argosy.buildName;24var name = buildName('John', 'Doe');

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var buildName = argosy.buildName;3var name = buildName('John', 'Doe');4console.log(name);5var argosy = require('argosy');6var buildName = argosy.buildName;7var name = buildName('John', 'Doe');8console.log(name);9var argosy = require('argosy');10var buildName = argosy.buildName;11var name = buildName('John', 'Doe');12console.log(name);13var argosy = require('argosy');14var buildName = argosy.buildName;15var name = buildName('John', 'Doe');16console.log(name);17var argosy = require('argosy');18var buildName = argosy.buildName;19var name = buildName('John', 'Doe');20console.log(name);21var argosy = require('argosy');22var buildName = argosy.buildName;23var name = buildName('John', 'Doe');24console.log(name);25var argosy = require('argosy');26var buildName = argosy.buildName;27var name = buildName('John', 'Doe');28console.log(name);29var argosy = require('argosy');30var buildName = argosy.buildName;31var name = buildName('John', 'Doe');32console.log(name);

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require("argosy");2var buildName = argosy.buildName;3var fullName = buildName("John","Doe");4console.log(fullName);5var argosy = require("argosy");6argosy.buildName("John","Doe");7var argosy = require("argosy");8argosy.buildName("John","Doe");9var argosy = require("argosy");10var fullName = argosy.buildName("John","Doe");11console.log(fullName);12var argosy = require("argosy");13var fullName = argosy.buildName("John","Doe");14console.log(fullName);15var argosy = require("argosy");16var fullName = argosy.buildName("John","Doe");17console.log(fullName);18var argosy = require("argosy");19var fullName = argosy.buildName("John","Doe");20console.log(fullName);21var argosy = require("argosy");22var fullName = argosy.buildName("John","Doe");23console.log(fullName);24var argosy = require("argosy");25var fullName = argosy.buildName("John","Doe");26console.log(fullName);27var argosy = require("argosy");28var fullName = argosy.buildName("John","Doe");29console.log(fullName);30var argosy = require("argosy");31var fullName = argosy.buildName("John","Doe");32console.log(fullName);33var argosy = require("argosy");34var fullName = argosy.buildName("John","Doe");35console.log(fullName);36var argosy = require("argosy");37var fullName = argosy.buildName("John","Doe");38console.log(fullName);39var argosy = require("argosy");40var fullName = argosy.buildName("John","Doe");41console.log(fullName);

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var myName = argosy.buildName("John","Doe");3console.log('My name is '+myName);4var argosy = require('argosy');5var myName = argosy.buildName("John","Doe");6console.log('My name is '+myName);7var argosy = require('argosy');8var myName = argosy.buildName("John","Doe");9console.log('My name is '+myName);10(function (module, exports) {11 var argosy = require('argosy');12 var myName = argosy.buildName("John","Doe");13 console.log('My name is '+myName);14})(module, exports);15var argosy = require('argosy');16var myName = argosy.buildName("John","Doe");17console.log('My name is '+myName);18(function (module, exports) {19 var argosy = require('argosy');20 var myName = argosy.buildName("John","Doe");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful