HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
x
 
function is(x, y) {
  return (
    (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
  );
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function shallowEqual(objA, objB) {
    if (is(objA, objB)) {
        return true;
    }
    if (
        typeof objA !== 'object' ||
        objA === null ||
        typeof objB !== 'object' ||
        objB === null
    ) {
        return false;
    }
    const keysA = Object.keys(objA);
    const keysB = Object.keys(objB);
    if (keysA.length !== keysB.length) {
        return false;
    }
    // Test for A's keys different from B.
    for (let i = 0; i < keysA.length; i++) {
        const currentKey = keysA[i];
        if (
            !hasOwnProperty.call(objB, currentKey) ||
            !is(objA[currentKey], objB[currentKey])
        ) {
            return false;
        }
    }
    return true;
}
var data = [{
    foo: {
        bar: {
            foo: {
                bar: ''
            }
        }
    }
}, {}, {}];
Tests:
  • Ramda

     
    var result = R.equals(data, [{foo: {bar: {foo: {bar: ''}}}}, {}, {}]);
  • shallowEqual

     
    var result = shallowEqual(data, [{foo: {bar: {foo: {bar: ''}}}}, {}, {}]);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Ramda
    shallowEqual

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 6 months ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123 on Linux
View result in a separate tab
Test name Executions per second
Ramda 190091.5 Ops/sec
shallowEqual 1477757.4 Ops/sec