Skip to content
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

Comparing large arrays can take forever #56

Open
Kagan-Of-Sky opened this issue Aug 21, 2020 · 2 comments
Open

Comparing large arrays can take forever #56

Kagan-Of-Sky opened this issue Aug 21, 2020 · 2 comments

Comments

@Kagan-Of-Sky
Copy link

To reproduce:

`const deepObjectDiff = require("deep-object-diff");

let a = new Array(10000);

for(let i=0; i<a.length; ++i){
a[i] = {
"attribute 1": i,
"attribute 2": i,
"attribute 3": i
};
}

let b = JSON.parse(JSON.stringify(a));
b.unshift({
"a": 9999999
});

let start = new Date().getTime();

let diff = deepObjectDiff.detailedDiff(a,b);

let end = new Date().getTime();
console.log("Took " + (end - start) + " milliseconds.")`

For an array of size 10000, it can take 40+ seconds.
20000 = about 250 seconds
25000 = about 500 seconds
If the array is very large, 100000+ , it can take a really long time.

@anko
Copy link
Contributor

anko commented Aug 21, 2020

What is the problem here? Bigger inputs take more time to process, and detailedDiff is the most expensive type of diff operation. Such an operation taking a while to process in JavaScript seems like expected behaviour.

@Kagan-Of-Sky
Copy link
Author

Fair enough.
It does seem like a weakness in the algorithm though. 8+ minutes to process an array of 25000 simple objects seems like a bit much. I would expect such an operation to take maybe a minute max and not scale exponentially - then again I am not at all familiar with the internals of doing a detailed diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants