Lo-Dash vs Underscore vs JSON.stringify() _.isEqual (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script>
var underscore = _.noConflict();
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js"></script>
<script>
var lodash = _.noConflict();
</script>

Setup

var obj1 = {
        properties: {
            selectionName: null,
            price: {
              format: 'fractional',
              odds: null
            },
            status: 'A',
            display: {
                displayed: 'Y',
                order: null
            },
            selectionScore: {
                home: null,
                away: null
            },
            band: {
                lower: 5,
                upper: 10
            },
            channels: 'ZWIP'
        },
        result: null
    };
    var obj2 = {
        properties: {
            selectionName: null,
            price: {
              format: 'fractional',
              odds: null
            },
            status: 'A',
            display: {
                displayed: 'Y',
                order: null
            },
            selectionScore: {
                home: null,
                away: null
            },
            band: {
                lower: null,
                upper: null
            },
            channels: 'ZWIP'
        },
        result: null
    };
    lodash = window.lodash;
    underscore = window.underscore

Test runner

Ready to run.

Testing in
TestOps/sec
lodash
window.lodash.isEqual(obj1, obj2);
ready
underscore
window.underscore.isEqual(obj1, obj2);
ready
JSON.stringify()
JSON.stringify(obj1) == JSON.stringify(obj2);
ready
Array LoDash
window.lodash.isEqual([1,2,3,4,5,6,7,8,9].sort(), [1,3,2,5,4,7,6,9,8].sort());
ready
Array underscore
window.underscore.isEqual([1,2,3,4,5,6,7,8,9].sort(),[1,3,2,5,4,7,6,9,8].sort());
ready
JSON Array
JSON.stringify([1,2,3,4,5,6,7,8,9].sort()) == JSON.stringify([1,3,2,5,4,7,6,9,8].sort());
ready
Intersection Array
a = [1,2,3,4,5,6,7,8,9];
b = [1,3,2,5,4,7,6,9,8];
a.length == b.length == window.underscore.intersection(a,b).length;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.