isEqual (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>

Setup

const has = Object.prototype.hasOwnProperty;
    function isEqual(a, b) {
      var ctor, len;
      if (a === b) return true;

      if (a && b && (ctor = a.constructor) === b.constructor) {
        if (ctor === Array) {
          if ((len = a.length) === b.length) {
            while (len-- && isEqual(a[len], b[len]));
          }
          return len === -1;
        }

        if (!ctor || typeof a === 'object') {
          len = 0;
          for (ctor in a) {
            if (has.call(a, ctor) && ++len && !has.call(b, ctor)) return false;
            if (!(ctor in b) || !isEqual(a[ctor], b[ctor])) return false;
          }
          return Object.keys(b).length === len;
        }
      }

      return a !== a && b !== b;
    }

    const obj = {
      weldPath: {
        id: '12507476135490790788',
        start: {
          pos: { x: -3805.80810546875, y: 973.0039672851562, z: 2052.06103515625 },
          axis: { x: -0.17364817766693033, y: 0, z: -0.9848077530122081 },
          correctionIds: [],
          offsetFrameIn: null,
          offsetFrameOut: { offsetX: { x: 0, y: 0, z: -1 }, offsetY: { x: 0, y: -1, z: 0 } }
        },
        segments: [
          {
            line: {
              to: {
                pos: { x: -3793.7961425781245, y: 973.0039672851562, z: 2052.06103515625 },
                axis: { x: -0.17364817766693033, y: 0, z: -0.9848077530122081 },
                correctionIds: [],
                offsetFrameIn: { offsetX: { x: 0, y: 0, z: -1 }, offsetY: { x: 0, y: -1, z: 0 } },
                offsetFrameOut: null
              }
            },
            weldType: { butt: { penetration: { mm: 0 } }, isTackWeld: false, isArcStartMotion: false },
            jointType: 'JOINT_EDGE',
            plates: {
              leftPlate: { orientation: { x: 0, y: 0, z: 1 }, thickness: { mm: 12.01196200000004 } },
              rightPlate: {
                orientation: { x: 0, y: 0.34202014332559266, z: 0.9396926207859361 },
                thickness: { mm: 0 }
              }
            },
            travelSpeed: null,
            voltage: null,
            pulsed: null,
            weaving: null,
            jobId: null,
            sequenceId: null,
            stickout: null
          }
        ],
        ancestorId: null,
        gravity: null,
        bounds: null,
        alternatives: [],
        nominalStickout: null,
        readableId: { text: 'Weld #1' },
        weldingParameters: [],
        crater: null,
        postIgnitionDelay: null
      },
      scene: {
        chains: [
          {
            uuid: '3ad8a595-f68c-4277-ad83-fc8026892f85',
            name: { text: 'Lascellen Produlas - Environment' },
            homeConfig: {},
            parentTChainRoot: {
              m00: 1,
              m01: 0,
              m02: 0,
              m03: 0,
              m10: 0,
              m11: 1,
              m12: 0,
              m13: 0,
              m20: 0,
              m21: 0,
              m22: 1,
              m23: 0,
              m30: 0,
              m31: 0,
              m32: 0,
              m33: 1
            },
            parent: null,
            chain: {
              rootJoint: {
                uuid: 'f5a3aed8-cfb9-44db-b28a-5f19898524d3',
                name: { text: 'Root' },
                visualGeometry: {
                  model: {
                    uuid: 'd7cad275d88c3695699ab5601203b295',
                    name: { text: 'f5a3aed8-cfb9-44db-b28a-5f19898524d3' },
                    identityTag: { genericIdentity: 'IDENTITY_CLASS_ROBOT_TOOL' },
                    parentTThis: {
                      m00: 1,
                      m01: 0,
                      m02: 0,
                      m03: 0,
                      m10: 0,
                      m11: 1,
                      m12: 0,
                      m13: 0,
                      m20: 0,
                      m21: 0,
                      m22: 1,
                      m23: 0,
                      m30: 0,
                      m31: 0,
                      m32: 0,
                      m33: 1
                    },
                    children: [],
                    data: [
                      {
                        uuid: '1ecafdca5c4ccddb5e8883f5f7a11388',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.VisualisationData',
                          file: {
                            file: 'gs://t-alpha-arcnc/app/europe-west1/alpha/job/6629257edf41f1544ea59af0/outputs/uploads/ui/2024/4/24/15/30/5/917/176a7314-eabb-4a04-ac71-625b0e884eb5/Lascellen Produlas - Environment.drc',
                            tags: { etag: '42a6ac321f2a55ff831fd4c9ea9f91ce' }
                          },
                          fileType: 'FILE_TYPE_DRC',
                          parentTThis: null,
                          quality: 'QUALITY_VISUALISATION_HIGH_QUALITY',
                          textures: []
                        },
                        validityTags: null
                      },
                      {
                        uuid: '3efd02d32807cc350b13a9cfd5c76c5a',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.TriMeshData',
                          file: {
                            file: 'gs://t-alpha-arcnc/app/europe-west1/alpha/job/6629257edf41f1544ea59af0/outputs/uploads/ui/2024/4/24/15/30/5/917/176a7314-eabb-4a04-ac71-625b0e884eb5/Lascellen Produlas - Environment.stl',
                            tags: { etag: '131c5a0803f7c735652ce5fa3820a3a2' }
                          },
                          fileType: 'FILE_TYPE_STL',
                          parentTThis: null,
                          state: 'GEOMETRY_STATE_UNHEALED_SOLID',
                          metaData: {
                            surfaceArea: { mm2: 456938620.079149 },
                            volume: { mm3: 20541013493.12645 },
                            triangleCount: { value: 1024 },
                            vertexCount: { value: 510 }
                          },
                          textures: []
                        },
                        validityTags: null
                      },
                      {
                        uuid: '416135a5813987564ee3a1dcba3aa4f4',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.Cuboid',
                          sizeX: { mm: 7000 },
                          sizeY: { mm: 18000 },
                          sizeZ: { mm: 2600.0000000000055 },
                          parentTThis: {
                            m00: 1,
                            m01: 0,
                            m02: 0,
                            m03: 0,
                            m10: 0,
                            m11: 1,
                            m12: 0,
                            m13: 0,
                            m20: 0,
                            m21: 0,
                            m22: 1,
                            m23: 0,
                            m30: 1796.0000000000002,
                            m31: 5104,
                            m32: 508.00000000000273,
                            m33: 1
                          }
                        },
                        validityTags: null
                      }
                    ],
                    persistentId: '4d43ff045ea5901674d5f70514b00967'
                  }
                },
                collisionGeometry: null
              },
              connectedJoints: [],
              type: 'KINEMATIC_CHAIN_TYPE_UNKNOWN'
            }
          }
        ],
        referenceConfigs: []
      },
      tool: {
        chain: { text: '4542bfaf-8dbf-4372-a140-d98bec51a733' },
        joint: { text: 'aaa0ea09-c249-4baa-a24d-88e6d211e891' }
      },
      weldPathPadding: [],
      motionStrategies: {
        strategies: [
          {
            weldPathModifications: {
              weldPathId: '12507476135490790788',
              modifications: [{ setTravelAngle: { section: null, value: { deg: -10 } } }]
            },
            score: { preferenceRank: 0 },
            jointMotionStrategies: [
              {
                joint: {
                  chain: { text: '956f5e83-ca14-489f-a1a4-bbc38488b474' },
                  joint: { text: '2198f557-520a-4039-9af4-415bf4f08573' }
                },
                unconstrained: {}
              },
              {
                joint: {
                  chain: { text: '7c9b2e7f-daac-4b60-8389-6e613cb1a130' },
                  joint: { text: '7de45e33-156f-4052-9a02-c29685663997' }
                },
                followLinearPath: { pathLengths: [], jointValuesRadMm: [0], jointValues: [] }
              },
              {
                joint: {
                  chain: { text: '7c9b2e7f-daac-4b60-8389-6e613cb1a130' },
                  joint: { text: '93c6593c-cb94-4d9a-8227-ae4f5af38ae2' }
                },
                followLinearPath: { pathLengths: [], jointValuesRadMm: [0], jointValues: [] }
              }
            ],
            reference: null,
            jointOrder: [],
            sceneMotion: null,
            coordinatedJoints: []
          },
          {
            weldPathModifications: {
              weldPathId: '12507476135490790788',
              modifications: [{ reverse: {} }, { setTravelAngle: { section: null, value: { deg: -10 } } }]
            },
            score: { preferenceRank: 0 },
            jointMotionStrategies: [
              {
                joint: {
                  chain: { text: '956f5e83-ca14-489f-a1a4-bbc38488b474' },
                  joint: { text: '2198f557-520a-4039-9af4-415bf4f08573' }
                },
                unconstrained: {}
              },
              {
                joint: {
                  chain: { text: '7c9b2e7f-daac-4b60-8389-6e613cb1a130' },
                  joint: { text: '7de45e33-156f-4052-9a02-c29685663997' }
                },
                followLinearPath: { pathLengths: [], jointValuesRadMm: [0], jointValues: [] }
              },
              {
                joint: {
                  chain: { text: '7c9b2e7f-daac-4b60-8389-6e613cb1a130' },
                  joint: { text: '93c6593c-cb94-4d9a-8227-ae4f5af38ae2' }
                },
                followLinearPath: { pathLengths: [], jointValuesRadMm: [0], jointValues: [] }
              }
            ],
            reference: null,
            jointOrder: [],
            sceneMotion: null,
            coordinatedJoints: []
          }
        ]
      },
      settings: {
        collisionPadding: { mm: 15 },
        taskToolNearPadding: { mm: 2.5 },
        nominalStickout: { mm: 17 },
        manipulatorStep: { deg: 45 }
      },
      weldingPositions: [
        {
          position: {
            mainPosition: 'WELDING_POSITION_PA',
            slope: { deg: 0 },
            minimalSlope: null,
            maximalSlope: null,
            rotation: { deg: 0 },
            minimalRotation: null,
            maximalRotation: null
          },
          travelAngle: { deg: 0 }
        }
      ],
      shouldFixWeldDirection: false
    };

    const obj2 = {
      weldPath: {
        id: '12507476135490790788',
        start: {
          pos: { x: -3805.80810546875, y: 973.0039672851562, z: 2052.06103515625 },
          axis: { x: -0.17364817766693033, y: 0, z: -0.9848077530122081 },
          correctionIds: [],
          offsetFrameIn: null,
          offsetFrameOut: { offsetX: { x: 0, y: 0, z: -1 }, offsetY: { x: 0, y: -1, z: 0 } }
        },
        segments: [
          {
            line: {
              to: {
                pos: { x: -3793.7961425781245, y: 973.0039672851562, z: 2052.06103515625 },
                axis: { x: -0.17364817766693033, y: 0, z: -0.9848077530122081 },
                correctionIds: [],
                offsetFrameIn: { offsetX: { x: 0, y: 0, z: -1 }, offsetY: { x: 0, y: -1, z: 0 } },
                offsetFrameOut: null
              }
            },
            weldType: { butt: { penetration: { mm: 0 } }, isTackWeld: false, isArcStartMotion: false },
            jointType: 'JOINT_EDGE',
            plates: {
              leftPlate: { orientation: { x: 0, y: 0, z: 1 }, thickness: { mm: 12.01196200000004 } },
              rightPlate: {
                orientation: { x: 0, y: 0.34202014332559266, z: 0.9396926207859361 },
                thickness: { mm: 0 }
              }
            },
            travelSpeed: null,
            voltage: null,
            pulsed: null,
            weaving: null,
            jobId: null,
            sequenceId: null,
            stickout: null
          }
        ],
        ancestorId: null,
        gravity: null,
        bounds: null,
        alternatives: [],
        nominalStickout: null,
        readableId: { text: 'Weld #1' },
        weldingParameters: [],
        crater: null,
        postIgnitionDelay: null
      },
      scene: {
        chains: [
          {
            uuid: '3ad8a595-f68c-4277-ad83-fc8026892f85',
            name: { text: 'Lascellen Produlas - Environment' },
            homeConfig: {},
            parentTChainRoot: {
              m00: 1,
              m01: 0,
              m02: 0,
              m03: 0,
              m10: 0,
              m11: 1,
              m12: 0,
              m13: 0,
              m20: 0,
              m21: 0,
              m22: 1,
              m23: 0,
              m30: 0,
              m31: 0,
              m32: 0,
              m33: 1
            },
            parent: null,
            chain: {
              rootJoint: {
                uuid: 'f5a3aed8-cfb9-44db-b28a-5f19898524d3',
                name: { text: 'Root' },
                visualGeometry: {
                  model: {
                    uuid: 'd7cad275d88c3695699ab5601203b295',
                    name: { text: 'f5a3aed8-cfb9-44db-b28a-5f19898524d3' },
                    identityTag: { genericIdentity: 'IDENTITY_CLASS_ROBOT_TOOL' },
                    parentTThis: {
                      m00: 1,
                      m01: 0,
                      m02: 0,
                      m03: 0,
                      m10: 0,
                      m11: 1,
                      m12: 0,
                      m13: 0,
                      m20: 0,
                      m21: 0,
                      m22: 1,
                      m23: 0,
                      m30: 0,
                      m31: 0,
                      m32: 0,
                      m33: 1
                    },
                    children: [],
                    data: [
                      {
                        uuid: '1ecafdca5c4ccddb5e8883f5f7a11388',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.VisualisationData',
                          file: {
                            file: 'gs://t-alpha-arcnc/app/europe-west1/alpha/job/6629257edf41f1544ea59af0/outputs/uploads/ui/2024/4/24/15/30/5/917/176a7314-eabb-4a04-ac71-625b0e884eb5/Lascellen Produlas - Environment.drc',
                            tags: { etag: '42a6ac321f2a55ff831fd4c9ea9f91ce' }
                          },
                          fileType: 'FILE_TYPE_DRC',
                          parentTThis: null,
                          quality: 'QUALITY_VISUALISATION_HIGH_QUALITY',
                          textures: []
                        },
                        validityTags: null
                      },
                      {
                        uuid: '3efd02d32807cc350b13a9cfd5c76c5a',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.TriMeshData',
                          file: {
                            file: 'gs://t-alpha-arcnc/app/europe-west1/alpha/job/6629257edf41f1544ea59af0/outputs/uploads/ui/2024/4/24/15/30/5/917/176a7314-eabb-4a04-ac71-625b0e884eb5/Lascellen Produlas - Environment.stl',
                            tags: { etag: '131c5a0803f7c735652ce5fa3820a3a2' }
                          },
                          fileType: 'FILE_TYPE_STL',
                          parentTThis: null,
                          state: 'GEOMETRY_STATE_UNHEALED_SOLID',
                          metaData: {
                            surfaceArea: { mm2: 456938620.079149 },
                            volume: { mm3: 20541013493.12645 },
                            triangleCount: { value: 1024 },
                            vertexCount: { value: 510 }
                          },
                          textures: []
                        },
                        validityTags: null
                      },
                      {
                        uuid: '416135a5813987564ee3a1dcba3aa4f4',
                        data: {
                          '@type': 'type.googleapis.com/oqton.common.geometry.Cuboid',
                          sizeX: { mm: 7000 },
                          sizeY: { mm: 18000 },
                          sizeZ: { mm: 2600.0000000000055 },
                          parentTThis: {
                            m00: 1,
                            m01: 0,
                            m02: 0,
                            m03: 0,
                            m10: 0,
                            m11: 1,
                            m12: 0,
                            m13: 0,
                            m20: 0,
                            m21: 0,
                            m22: 1,
                            m23: 0,
                            m30: 1796.0000000000002,
                            m31: 5104,
                            m32: 508.00000000000273,
                            m33: 1
                          }
                        },
                        validityTags: null
                      }
                    ],
                    persistentId: '4d43ff045ea5901674d5f70514b00967'
                  }
                },
                collisionGeometry: null
              },
              connectedJoints: [],
              type: 'KINEMATIC_CHAIN_TYPE_UNKNOWN'
            }
          }
        ],
        referenceConfigs: []
      },
      tool: {
        chain: { text: '4542bfaf-8dbf-4372-a140-d98bec51a733' },
        joint: { text: 'aaa0ea09-c249-4baa-a24d-88e6d211e891' }
      },
      weldPathPadding: [],
      motionStrategies: obj.motionStrategies,
      settings: {
        collisionPadding: { mm: 15 },
        taskToolNearPadding: { mm: 2.5 },
        nominalStickout: { mm: 17 },
        manipulatorStep: { deg: 45 }
      },
      weldingPositions: [
        {
          position: {
            mainPosition: 'WELDING_POSITION_PA',
            slope: { deg: 0 },
            minimalSlope: null,
            maximalSlope: null,
            rotation: { deg: 0 },
            minimalRotation: null,
            maximalRotation: null
          },
          travelAngle: { deg: 0 }
        }
      ],
      shouldFixWeldDirection: false
    };

Test runner

Ready to run.

Testing in
TestOps/sec
lodash
return _.isEqual(obj, obj2)
ready
fast isEqual
return isEqual(obj, obj2)
ready

Revisions

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