Comments (9)
I will try to benchmark this later. If the results show that cyclical reference checking slows nested objects down enough, I will add an option to disable the checking.
from microdiff.
I decided to add an option in v1.2.0, so by default, cycles are checked, but you can disable it as specified in the README and release notes.
from microdiff.
Benchmark it.
from microdiff.
Don't be silly, the overhead in both complexity, memory use, and code size is negligible (see for yourself 3b6ab8f), and it serves the important purpose of not creating situations where using this library would potentially crash the process or exhaust your server's memory. For such a small addition (less than 2 lines of code) that's a huge win.
from microdiff.
That totally depends on the size of the objects. If the user knows that there are no circular references, why have the runtime check it at all?
For big JSON blobs with many objects, this will severely impact performance by having to
- reallocate the array
- linearly search for references for every addition
Sure, it is assumed that it is small, but performance almost doesn't matter in the small anyway, so why micro-optimize then?
from microdiff.
I don't have the incentive to put that amount of time in, I don't even use the lib. Just wanted to put this issue out there.
from microdiff.
For most objects with low depth, as expected, there is little to no difference. However, with highly nested objects, I noticed a difference of around 30%. Should I add an option to disable it? Having the choice would increase code size slightly and reduce performance slightly, but it would overall be faster if you disable checking, and you can still keep checking if you want.
from microdiff.
Great work! 🎉🙌
One thing we could try before using a flag is to use a Set
instead of an Array
. How does that affect performance?
I think a 3% pessimization or so is where I'd feel alright about it personally, because if one only diffs large JSON blobs which just arrived serialized over the network, there is no need to check for circular dependencies, so it would feel silly to miss out on something like every 20th diff (in the case of 5% e.g.)
from microdiff.
Nicely done!
from microdiff.
Related Issues (20)
- Recreation from diff HOT 8
- Does not handle object changes within array HOT 2
- How about having index path for array be a number instead of a string? HOT 2
- Is it possible to see the old value? HOT 2
- Consider supporting JSONPatch HOT 10
- Question: any recommendation on how to visualize the output? HOT 7
- Possible optimization: hashing HOT 2
- UMD bundle HOT 2
- support for NaN values HOT 1
- Ineficient change detection HOT 1
- Community Exchange Introduction/Tracking HOT 6
- Add templates for issues HOT 2
- Update README.md HOT 2
- Add Code of Conduct HOT 2
- get array removals as "DELETE" HOT 7
- ➕ Feature - Export DIFFERENCE Type so it can be imported in Ts projects HOT 2
- Inconsistent diff Behavior for Object-derived Type Changes HOT 2
- Extend the diff function with rich types not included in the base JS language. HOT 1
- Cannot use 'in' operator to search for ... in null HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microdiff.