complete comparison undescore and lodash

JavaScript performance comparison

Test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js">
</script>
<script>
  var un = _.noConflict();
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.1.1/lodash.min.js">
</script>
<script>
  var lo = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var obj = {
      "qdk": "ppf",
      "pdf": "qpn",
      "knl": "fqp",
      "dfa": "qqn",
      "pnn": "fsk",
      "kqp": "akq",
      "qfs": "sqa",
      "ldl": "lld",
      "nsk": "kaf",
      "aqq": "qap",
      "fdl": "kla",
      "anq": "pfa",
      "lpq": "qnq",
      "ffl": "pfa",
      "fkd": "sdf",
      "snk": "adp",
      "lan": "ddl",
      "aak": "sqs",
      "qsa": "ldd",
      "lql": "nfd",
      "dnf": "qda",
      "pqp": "lsn",
      "qaf": "kqs",
      "lls": "pdp",
      "snl": "klp",
      "lqa": "kpn",
      "nll": "pkf",
      "ddq": "kkq",
      "knf": "nfd",
      "adf": "fpf",
      "qkf": "lak",
      "fdn": "nfa",
      "fff": "dpk",
      "nnk": "lqq",
      "dfp": "ndn",
      "sfn": "kpf",
      "sda": "aks",
      "nkd": "qsk",
      "ndn": "ppf",
      "ldn": "lfl",
      "kdf": "llp",
      "fka": "slq",
      "ksn": "alp",
      "fdp": "qan",
      "fkq": "qsf",
      "dsn": "ank",
      "pkq": "dfn",
      "npf": "dlf",
      "asf": "fnl",
      "slp": "pdf",
      "ndd": "lka",
      "qan": "dkp",
      "spq": "lnl",
      "ads": "spa",
      "qfk": "npa",
      "aqd": "kla",
      "ffn": "qpq",
      "lsl": "lqa",
      "lnd": "fls",
      "dla": "sas",
      "fla": "sla",
      "fas": "kaq",
      "lpn": "qkp",
      "lnn": "aap",
      "pan": "qfq",
      "ssf": "sfp",
      "nss": "qnq",
      "kan": "dfn",
      "sas": "ksn",
      "skl": "lfn",
      "nal": "kdn",
      "naf": "lnn",
      "nsp": "pqf",
      "asq": "lps",
      "nql": "lkp",
      "kfk": "pfd",
      "ppl": "fsd",
      "faf": "psd",
      "fqd": "asa",
      "qnn": "nqa",
      "kpd": "klq",
      "pdk": "lal",
      "sdq": "qfn",
      "app": "apa",
      "qqd": "adq",
      "aas": "sfd",
      "lfd": "kds",
      "fnl": "kkq",
      "ssa": "sqk",
      "qfp": "nfs",
      "sds": "kaq",
      "aal": "nlk",
      "snn": "psk",
      "dll": "lnf",
      "ldk": "add",
      "dql": "pnd",
      "snf": "nfa",
      "knp": "sfq",
      "lds": "lnd",
      "snd": "qad",
      "sfp": "kdq",
      "kkl": "dfs",
      "afn": "ssp",
      "knk": "lal",
      "qna": "qsd",
      "nsf": "kdn",
      "qss": "alk",
      "ann": "ffd",
      "qfq": "fff",
      "adq": "fdd",
      "psp": "ldf",
      "fdd": "aqp",
      "adl": "kfl",
      "ldf": "kfs",
      "kqf": "ddn",
      "dlk": "nld",
      "fpl": "kpd",
      "sff": "sff",
      "lfk": "ndp",
      "kql": "ksf",
      "lpp": "lld",
      "dak": "and",
      "kkk": "naf",
      "kld": "lsl",
      "lsn": "anl",
      "kps": "fad",
      "nnp": "dqf",
      "qla": "pla",
      "nna": "qal",
      "fdf": "fkq",
      "sal": "sff",
      "fns": "ala",
      "dps": "nsk",
      "dkn": "lsl",
      "lkl": "ldk",
      "afk": "sdn",
      "las": "lla",
      "nqs": "nnf",
      "adk": "qkd",
      "ksk": "alp",
      "dsa": "ddf",
      "dad": "slp",
      "lap": "nfd",
      "aks": "kdp",
      "qql": "npk",
      "slq": "qls",
      "npl": "fds",
      "kfd": "knk",
      "qqp": "dnl",
      "sfl": "dpq",
      "fda": "kpa",
      "lqq": "qqn",
      "faq": "npf",
      "pqf": "dpl",
      "fss": "apf",
      "klq": "sns",
      "psf": "qpq",
      "ppk": "llp",
      "fqk": "sqs",
      "kpn": "skp",
      "afd": "dfd",
      "qnk": "nkq",
      "dkd": "nfn",
      "sad": "qfa",
      "aad": "lnk",
      "nak": "knd",
      "qdn": "ada",
      "qks": "fqp",
      "pfl": "snl",
      "lkp": "aas",
      "ksd": "dlp",
      "sln": "kfl",
      "nkp": "lsk",
      "aqa": "pfs",
      "sfs": "ana",
      "kda": "dka",
      "lns": "sap",
      "qpl": "nps",
      "pls": "ask",
      "asa": "nql",
      "fpa": "ndk",
      "dkf": "lqs",
      "pds": "kqa",
      "lqp": "ddn",
      "anp": "sfs",
      "alp": "spk",
      "paf": "kkl",
      "spa": "ffn",
      "nps": "qqf",
      "dpk": "lnp",
      "ffd": "lad",
      "qkl": "fss",
      "fqq": "pqs",
      "adp": "ada",
      "pll": "akl",
      "sns": "alq",
      "lkf": "kls",
      "akf": "qps",
      "fnd": "kff",
      "qfd": "aqn",
      "kdq": "lnl",
      "plk": "dnp",
      "nds": "lsp",
      "fsd": "fnq",
      "kfp": "ksp",
      "saf": "kpf",
      "slk": "slp",
      "kqd": "nnp",
      "paq": "ddf",
      "ndl": "dsf",
      "nkk": "sfs",
      "pss": "pks",
      "add": "sqa",
      "qqs": "kdd",
      "lpd": "lak",
      "naa": "lnp",
      "dal": "nnf",
      "fsa": "sdl",
      "aff": "qnf",
      "qpf": "kak",
      "nqn": "lkf",
      "kap": "plf",
      "nls": "lfl",
      "lll": "lfn",
      "qdd": "qnf",
      "dnd": "kpa",
      "lsk": "qnf",
      "qpn": "fkd",
      "dlp": "anl",
      "dnp": "dnf",
      "lsp": "sla",
      "aqk": "sfn",
      "nsd": "qal",
      "lka": "qld",
      "qda": "sdp",
      "dnn": "fkf",
      "nfn": "pda",
      "dpp": "kdd",
      "ada": "fns",
      "pnl": "nds",
      "nqa": "pqd",
      "ksf": "pqd",
      "anf": "qsn",
      "dqq": "skp",
      "all": "nfp",
      "kdk": "dpn",
      "qdq": "dqf",
      "ddp": "kpf",
      "lpa": "fqk",
      "pad": "kak",
      "ala": "qfa",
      "fql": "sns",
      "qsq": "ndk",
      "spl": "dak",
      "fnn": "pak",
      "akp": "aqs",
      "apf": "akd",
      "npd": "aqn",
      "qpq": "ndf",
      "qdf": "npa",
      "fak": "ksd",
      "saa": "lpn",
      "laq": "ada",
      "sdf": "all",
      "nqk": "fnq",
      "ndq": "lnl",
      "psn": "aka",
      "dqs": "kfp",
      "pla": "qqd",
      "fan": "adp",
      "ldd": "snk",
      "qnf": "lla",
      "kqa": "npk",
      "fkp": "qqn",
      "lnl": "kds",
      "dqn": "lqk",
      "kas": "aqk",
      "pdn": "pqs",
      "nqp": "slf",
      "ppp": "nsk",
      "qpp": "sdn",
      "pks": "qps",
      "ska": "nnk",
      "afs": "qnd",
      "lln": "dpn",
      "pdd": "nqa",
      "qld": "qlq",
      "dqk": "dak",
      "qkd": "naa",
      "nqq": "fkf",
      "ssq": "sla",
      "psd": "qps",
      "kqn": "kqp",
      "llq": "anl",
      "fls": "aqd",
      "qsf": "aka",
      "lpl": "dfk",
      "dka": "dak",
      "lfp": "kkf",
      "lld": "qdk",
      "kll": "kqk",
      "asp": "daa",
      "apk": "kfl",
      "kdp": "fss",
      "als": "sns",
      "ssp": "nll",
      "kad": "fsa",
      "sps": "dkp",
      "ksa": "kqp",
      "lfa": "ddp",
      "kpa": "nfs",
      "skp": "psf",
      "pdp": "dfn",
      "akq": "lka",
      "dsp": "aas",
      "lak": "nqa",
      "sqa": "dpq",
      "sfa": "dpn",
      "spd": "pnn",
      "sqq": "kda",
      "fna": "nlq",
      "sqp": "lfa",
      "qqf": "dnn",
      "pqn": "anq",
      "dns": "spp",
      "sak": "dpa",
      "pkl": "ask",
      "qlf": "slq",
      "skk": "qna",
      "qkn": "lnk",
      "nlf": "qqn",
      "qnl": "lqn",
      "qak": "psq",
      "apn": "lsa",
      "kfn": "dfa",
      "aan": "qdq",
      "ddl": "dfn",
      "sdl": "dnp",
      "qns": "fsf",
      "kkq": "fqp",
      "npa": "npq",
      "qll": "qdf",
      "kfs": "klq",
      "kaq": "ada",
      "qap": "sld",
      "kqk": "sla",
      "qas": "qdf",
      "dsf": "dnn",
      "lqd": "fad",
      "nks": "saq",
      "lsf": "asf",
      "fkl": "kfq",
      "ffa": "dka",
      "qpk": "dkk",
      "faa": "dnk",
      "lks": "nnn",
      "pkd": "nfk",
      "fad": "fdl",
      "fsp": "nkd",
      "pld": "qlk",
      "dln": "sdn",
      "kpq": "psf",
      "nfa": "kdf",
      "lqk": "aln",
      "nns": "npl",
      "dpf": "laq",
      "dlf": "pad",
      "llk": "fpn",
      "klk": "adp",
      "flp": "ssk",
      "sdp": "lap",
      "dfd": "dpl",
      "qad": "slk",
      "pfa": "lfa",
      "ndk": "kkp",
      "fsq": "lsp",
      "ffq": "flq",
      "dff": "faq",
      "dls": "lnl",
      "ppn": "lqn",
      "das": "ldk",
      "akn": "ffp",
      "pfd": "lka",
      "dkk": "pal",
      "ndp": "psf",
      "pfq": "sss",
      "sqf": "ppd",
      "snp": "fla",
      "sqs": "akd",
      "fln": "ddp",
      "pfn": "ssq",
      "nnn": "npa",
      "ssl": "afq",
      "nda": "snl",
      "spp": "faf",
      "dpl": "spl",
      "lqn": "dps",
      "aqs": "npq",
      "sqd": "qdk",
      "lnf": "dpd",
      "knn": "adp",
      "psk": "dqd",
      "nka": "fks",
      "fsn": "pdl",
      "aaf": "apf",
      "kpp": "fsf",
      "lkn": "ppn",
      "plp": "asf",
      "qlq": "dpp",
      "dnk": "lnn",
      "kqq": "qds",
      "fsl": "nld",
      "aqp": "lnf",
      "dsd": "nns",
      "dda": "fdf",
      "ssd": "ffp",
      "nfp": "sdk",
      "asd": "qfq",
      "klf": "lpk",
      "kak": "fqp",
      "nnq": "npk",
      "daa": "ksp",
      "pqd": "fpl",
      "flq": "ppd",
      "lqf": "nlq",
      "dkl": "kls",
      "pfs": "lfa",
      "qds": "qsf",
      "lsd": "nkk",
      "ddd": "pqp",
      "fal": "lkq",
      "dkq": "nlq",
      "lnq": "akl",
      "ald": "dqf",
      "qls": "pap",
      "nsl": "lna",
      "pff": "qll",
      "dap": "dqq",
      "knd": "aas",
      "fdk": "kdp",
      "pqq": "lql",
      "qqq": "fls",
      "pkf": "fqa",
      "kfq": "ffn",
      "sfq": "dqk",
      "kaa": "aps",
      "flk": "dka",
      "afq": "pqn",
      "skf": "kaf",
      "qqa": "afq",
      "ass": "nqd",
      "spf": "slq",
      "pqa": "spf",
      "qln": "kks",
      "fqa": "knf",
      "lkd": "klq",
      "sld": "kdq",
      "sks": "psp",
      "npn": "ssl",
      "aps": "lnp",
      "fnq": "kfp",
      "sla": "aaa",
      "nsq": "pkq",
      "aaa": "klp",
      "qsp": "adl",
      "qsn": "kkl",
      "fpk": "pfl",
      "aaq": "lsa",
      "kkn": "kfa",
      "slf": "dpq",
      "ddf": "pla",
      "dks": "ans",
      "daq": "dnq",
      "dlq": "nqq",
      "nnf": "pnp",
      "lsq": "aan",
      "ppd": "snp",
      "kfl": "das",
      "nnd": "sqp",
      "nad": "dnf",
      "nfl": "dsq",
      "fpf": "dqn",
      "pfp": "sds",
      "fsf": "fap",
      "nlk": "fkp",
      "fkf": "kks",
      "nsn": "skd",
      "san": "fks",
      "fqn": "sfd",
      "naq": "kqn",
      "nas": "dqq",
      "asl": "nqs",
      "dkp": "dkl",
      "npp": "anp",
      "qka": "qaq",
      "lfl": "sdf",
      "aql": "fdk",
      "qqk": "pds",
      "lqs": "anp",
      "flf": "ssf",
      "npk": "ssa",
      "kdd": "nll",
      "kns": "dsf",
      "dqf": "sak",
      "spk": "qnn",
      "lff": "fkf",
      "ppq": "nla",
      "pln": "dkd",
      "dld": "lfa",
      "dss": "fsk",
      "lna": "spq",
      "nsa": "lsa",
      "dnl": "nsd",
      "nfq": "lsa",
      "ana": "dap",
      "pnf": "ffq",
      "qlk": "qaa",
      "fds": "qnn",
      "daf": "sap",
      "nla": "ldn",
      "qfl": "psk",
      "qpd": "pfn",
      "npq": "dql",
      "fld": "dpa",
      "qnd": "qns",
      "qdp": "fqq",
      "pka": "pdn",
      "lsa": "kfl",
      "kal": "laa",
      "skd": "aaa",
      "ppa": "fkl",
      "pkn": "psp",
      "ksq": "afl",
      "fqf": "nlq",
      "qsd": "lpn",
      "skn": "asa",
      "aqn": "nkk"
    };
    var arr = [402, 106, 600, 366, 432, 766, 30, 306, 917, 236, 779, 466, 218, 848, 120, 387, 81, 641, 307, 567, 541, 529, 447, 20, 67, 7, 195, 838, 691, 459, 890, 374, 432, 548, 348, 916, 738, 70, 600, 828, 864, 986, 997, 436, 564, 901, 621, 984, 642, 757, 905, 72, 115, 38, 693, 513, 891, 881, 919, 155, 58, 523, 692, 498, 641, 219, 368, 345, 612, 613, 660, 567, 577, 425, 761, 241, 597, 247, 617, 90, 88, 257, 981, 518, 793, 462, 564, 908, 966, 434, 475, 735, 926, 674, 850, 366, 550, 221, 83, 24, 447, 438, 588, 397, 356, 897, 116, 630, 352, 980, 663, 52, 151, 650, 189, 347, 319, 732, 26, 406, 939, 217, 451, 455, 148, 552, 109, 715, 914, 311, 703, 769, 967, 229, 418, 212, 489, 760, 933, 65, 666, 198, 781, 679, 731, 432, 618, 874, 246, 1000, 211, 968, 390, 782, 786, 891, 179, 15, 5, 571, 318, 972, 643, 827, 22, 917, 720, 738, 866, 755, 304, 593, 264, 356, 991, 524, 539, 866, 359, 416, 304, 150, 414, 401, 359, 660, 66, 365, 114, 372, 765, 772, 162, 303, 934, 888, 249, 283, 611, 160, 354, 575, 27, 719, 666, 128, 722, 719, 90, 513, 532, 671, 632, 520, 621, 784, 443, 799, 663, 877, 938, 432, 493, 876, 509, 769, 766, 800, 179, 218, 207, 609, 249, 89, 342, 824, 632, 192, 164, 483, 345, 808, 818, 165, 445, 622, 143, 904, 270, 849, 84, 385, 201, 437, 641, 602, 400, 795, 744, 969, 7, 865, 275, 212, 849, 95, 567, 232, 535, 147, 558, 451, 703, 810, 553, 444, 394, 894, 440, 322, 914, 749, 99, 135, 13, 432, 930, 338, 277, 315, 263, 265, 876, 813, 414, 140, 196, 628, 781, 399, 370, 275, 90, 183, 633, 636, 959, 80, 419, 734, 22, 210, 695, 615, 993, 433, 187, 340, 993, 120, 752, 189, 620, 24, 159, 155, 979, 833, 34, 379, 669, 707, 870, 533, 64, 104, 989, 958, 143, 53, 792, 13, 165, 532, 461, 542, 216, 44, 872, 558, 103, 860, 45, 524, 375, 880, 249, 390, 689, 417, 938, 693, 901, 767, 314, 907, 566, 174, 659, 798, 787, 115, 543, 892, 49, 912, 434, 497, 510, 935, 868, 781, 608, 218, 141, 640, 457, 440, 458, 170, 829, 991, 312, 663, 902, 576, 142, 558, 248, 8, 981, 666, 155, 562, 562, 50, 957, 715, 801, 240, 790, 723, 196, 742, 340, 705, 238, 919, 145, 455, 197, 834, 25, 490, 853, 106, 474, 72, 309, 200, 676, 520, 525, 247, 256, 593, 430, 861, 499, 737, 305, 937, 149, 834, 688, 737, 892, 221, 259, 592, 683, 472, 657, 631, 395, 440, 333, 552, 609, 589, 157, 855, 317, 739, 287, 740, 631, 121, 600, 349, 716, 720, 770, 954, 800, 929, 647, 563, 1000, 26, 555, 604, 613, 465, 939, 489, 155, 612, 248, 984, 33, 915, 428, 904, 916, 418, 377, 701, 757, 902, 460, 750, 778, 926, 616, 386, 903, 974, 555, 531, 639, 748, 508, 567, 342, 375, 201, 43, 710, 287, 917, 741, 291, 280, 13, 797, 666, 201, 62, 24, 782, 867, 175, 284, 545, 781, 558, 301, 873, 624, 341, 519, 974, 381, 282, 537, 178, 112, 537, 466, 110, 375, 622, 623, 703, 928, 309, 473, 606, 422, 288, 869, 303, 198, 124, 51, 253, 457, 590, 32, 569, 741, 677, 351, 112, 770, 457, 742, 861, 422, 765, 419, 984, 819, 27, 116, 898, 262, 293, 751, 844, 126, 602, 444, 711, 706, 376, 370, 167, 898, 718, 337, 419, 680, 737, 26, 85, 26, 80, 216, 235, 640, 121, 453, 396, 301, 860, 39, 396, 471, 952, 464, 352, 888, 470, 799, 112, 594, 629, 222, 669, 22, 312, 377, 738, 154, 678, 735, 962, 199, 380, 93, 881, 152, 465, 341, 177, 634, 144, 83, 40, 789, 366, 654, 507, 930, 719, 996, 202, 385, 318, 246, 190, 630, 385, 201, 263, 518, 885, 980, 111, 808, 892, 483, 639, 5, 719, 389, 540, 482, 477, 685, 84, 628, 863, 249, 716, 226, 398, 206, 641, 860, 257, 520, 331, 96, 632, 998, 949, 965, 184, 644, 253, 317, 552, 921, 614, 959, 723, 610, 264, 734, 494, 805, 703, 729, 275, 710, 433, 135, 315, 106, 28, 191, 384, 822, 563, 911, 424, 516, 89, 953, 39, 288, 610, 854, 368, 179, 172, 102, 906, 665, 19, 970, 742, 677, 918, 562, 653, 524, 330, 583, 693, 595, 359, 75, 45, 667, 721, 767, 508, 693, 126, 549, 220, 549, 896, 664, 171, 766, 236, 868, 747, 658, 367, 849, 916, 194, 737, 336, 101, 154, 774, 518, 536, 888, 288, 170, 500, 324, 269, 717, 443, 595, 754, 778, 898, 304, 144, 56, 345, 177, 340, 547, 406, 547, 537, 816, 449, 933, 121, 472, 798, 295, 305, 986, 111, 147, 657, 181, 817, 39, 16, 599, 569, 429, 360, 504, 383, 766, 802, 118, 202, 97, 736, 91, 239, 214, 359, 178, 782, 679, 334, 211, 203, 395, 680, 779, 13, 394, 468, 33, 634, 753, 988, 317, 301, 97, 441, 384, 746, 69, 624, 101, 452, 664, 461, 694, 253, 398, 568, 199, 558, 965, 8, 61, 32, 51, 227, 841, 156, 876, 641, 69, 913, 671, 87, 110, 293, 378, 873, 667, 367, 602, 469, 808, 184, 28, 12, 579, 660, 219, 255, 604, 374, 897, 188, 795, 526, 866, 52, 629, 221, 150, 799, 659, 197, 100, 281, 451, 427, 992, 316, 69, 672, 359, 62, 914, 714, 550, 905, 518, 235, 799, 747, 826, 963, 289, 377, 39, 463, 282, 356, 508, 69, 543, 251, 79, 976, 409, 901, 569, 578, 345, 462, 10, 541, 710, 102, 156, 759, 394, 470, 967, 542, 612, 515, 7, 207, 529, 681, 231, 224, 37, 895, 293, 747, 846, 224, 126, 961, 907, 217, 562, 383, 616, 702, 480, 63, 116, 983, 77, 796, 520, 180, 231, 269, 7, 747, 230];
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
underscore
var finish = {};
un.each(obj, function(e, k) {
  finish[e] = k;
});
finish = un.extend(obj, finish);
finish = un.contains(arr, 39);
finish = un.keys(obj);
finish = un.min(arr);
finish = un.values(obj);
finish = un.indexOf(arr, 734);
finish = un.clone(obj);
finish = un.uniq(arr);
finish = un.invert(obj);
finish = un.sortBy(arr, function(e) {
  return e;
});
finish = un.map(arr, function(e, k) {
  return (e < 500 ? e * 2 : e - k);
});
finish = un.intersection(arr, finish);
finish = un.size(obj);
finish = un.filter(arr, function(e) {
  return e < 500;
});
finish = un.toArray(obj);
finish = un.reduce(arr, function(memo, num) {
  return memo + num;
}, 0);
finish = un.groupBy(arr, function(e) {
  return e % 2
});
pending…
lodash
var finish = {};
lo.each(obj, function(e, k) {
  finish[e] = k;
});
finish = lo.extend(obj, finish);
finish = lo.contains(arr, 39);
finish = lo.keys(obj);
finish = lo.min(arr);
finish = lo.values(obj);
finish = lo.indexOf(arr, 734);
finish = lo.clone(obj);
finish = lo.uniq(arr);
finish = lo.invert(obj);
finish = lo.sortBy(arr, function(e) {
  return e;
});
finish = lo.map(arr, function(e, k) {
  return (e < 500 ? e * 2 : e - k);
});
finish = lo.intersection(arr, finish);
finish = lo.size(obj);
finish = lo.filter(arr, function(e) {
  return e < 500;
});
finish = lo.toArray(obj);
finish = lo.reduce(arr, function(memo, num) {
  return memo + num;
}, 0);
finish = lo.groupBy(arr, function(e) {
  return e % 2
});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment