GithubHelp home page GithubHelp logo

deep-equal performance benchmark about monolite HOT 3 CLOSED

kube avatar kube commented on May 29, 2024 1
deep-equal performance benchmark

from monolite.

Comments (3)

kube avatar kube commented on May 29, 2024 2

Thanks for your report and benchmark.

It was already planned to bundle a custom and limited deepEqual function, as most of the checks done by generic deepEqual libraries are not necessary in the context of monolite, and have a big impact on performance.

This will be the next perfomance optimization on monolite, along with the static accessor function resolution optimization once TypeScript officially provides custom AST transforms in version 2.3 (microsoft/TypeScript#13940).

from monolite.

drew-wallace avatar drew-wallace commented on May 29, 2024

I ran some tests myself.
Here is the test: https://gist.github.com/drew-wallace/2033bf6c9aedd1cfe09e78d8246949da
Here are the results of a single test run:

Test 1

  • lodash took 21.674999999999272 milliseconds: true false
  • stringify took 1192.65 milliseconds: true false
  • deepEqual took 749.0799999999999 milliseconds: true false
  • value_equal took 17.099999999999454 milliseconds: true false

Test 2

  • lodash took 27.395000000000437 milliseconds: true false
  • stringify took 1030.8950000000004 milliseconds: true false
  • deepEqual took 649.5 milliseconds: true false
  • value_equal took 17.3100000000004 milliseconds: true false

Test 3

  • lodash took 22.590000000000146 milliseconds: true false
  • stringify took 1092.255000000001 milliseconds: true false
  • deepEqual took 796.1800000000003 milliseconds: true false
  • value_equal took 16.904999999998836 milliseconds: true false

Test 4

  • lodash took 25.965000000000146 milliseconds: true false
  • stringify took 953.335000000001 milliseconds: true false
  • deepEqual took 618.0299999999988 milliseconds: true false
  • value_equal took 18.7549999999992 milliseconds: true false

Test 5

  • lodash took 21.404999999998836 milliseconds: true false
  • stringify took 1030.9050000000007 milliseconds: true false
  • deepEqual took 644.0100000000002 milliseconds: true false
  • value_equal took 8.524999999999636 milliseconds: true false

In other tests lodash would perform slower than all the others by a vast amount in Test 1 but subsequent tests showed a ramp up in performance most likely from caching the results.

I would advise switching to the value_equal or lodash isEqual functions I mentioned above for better performance.

from monolite.

kube avatar kube commented on May 29, 2024

I now provide a custom deepEqual function since 76c25a8.

It's intentionally limited, and will need to be enhanced in objectEqual function performance which uses Object.getOwnPropertyNames.

from monolite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.