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

Collapse a large compound node is slow #114

Open
bensonnw opened this issue Oct 14, 2020 · 2 comments
Open

Collapse a large compound node is slow #114

bensonnw opened this issue Oct 14, 2020 · 2 comments

Comments

@bensonnw
Copy link

bensonnw commented Oct 14, 2020

In our project, we have a compound node contains more than 17000 nodes, when collapsing it, it takes about 30 seconds. After some investigation, the API expandCollapseUtilities.removeChildren is taking most of the time, it seems like the following code inside the For loop is pretty expensive:

  ......
  var removedChild = child.remove();
  if (root._private.data.collapsedChildren == null) {
    root._private.data.collapsedChildren = removedChild;
  }
  else {
    root._private.data.collapsedChildren = root._private.data.collapsedChildren.union(removedChild);
  }

Instead of doing that, how about to move the code out of the loop and do something:

if (children.length > 0) {
  const removedChildren = children.remove();
  if (root._private.data.collapsedChildren == null) {
    root._private.data.collapsedChildren = removedChildren;
  }
  else {
    root._private.data.collapsedChildren = root._private.data.collapsedChildren.union(removedChildren);
  }
} 

This way needs much less time (drop to about 1 second) to run.

@hasanbalci
Copy link
Contributor

@bensonnw Thanks for your suggestion, we will evaluate it before the next release.

@bensonnw
Copy link
Author

@hasanbalci Thanks for quick response, would you mind to tell me when is your next release?

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