-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding triple equals check to avoid worst case #149
Conversation
Thanks for feedback, but I'm not quite sure I get your case. Could you add a test for that?
At which step it fails? https://github.com/Starcounter-Jack/JSON-Patch/blob/master/CONTRIBUTING.md#testing |
All tests are failing both in node and in browser, with this error:
I'm not sure how to add a test for this change, since its a performance improvement instead of a normal bug fix. For example:
|
Thanks, that makes a perfect sense. However we could add another benchmark for it
That's wierd, I have just cloned a fresh repo,and everything works fine. git clone https://github.com/Starcounter-Jack/JSON-Patch.git
cd JSON-Patch
npm install
npm test
npm run bench-duplex Could you provide a full log? |
I have added such case 3a020d0 Please tell me, is that what you were talking about? The difference is huge! So, we will definitely take this. But I'd like to check that there is nothing more to add. |
@tomalec Looks like the tests are working. Must have been something about my fork. The benchmarks look good. Might be worth adding a test for large arrays as well. Out of curiosity, do you have some before & after numbers? |
Would it be worth moving the check to the top of _generate, so we can capture the case of
|
Would you mind doing that? |
Here you have numbers before https://travis-ci.org/Starcounter-Jack/JSON-Patch#L637 You can check numbers after by merging with master :) |
@KamranAsif please let me know once you are finished with changes, so I'll merge this. |
Moving to top made it 123% faster! (37402/30403 op/sec) 🎉 |
Done :) |
But in total this change for object deep for 11 nodes gave us, waaay much better result |
Released as 1.1.7 |
Currently we walk through the entire subtree of the object. This change allows us to exit early if we see two objects with the same reference at a higher level.
I wasn't able to get the tests to work locally