deletePictogramElement Performance [message #873175] |
Thu, 17 May 2012 16:23 |
Craig Petre Messages: 32 Registered: April 2011 |
Member |
|
|
I'm seeing some performance problems with deleting elements from, what I would consider, a reasonably large diagram for my application. I've noticed that much of the time seems to be eaten up in PeService.deletePictogramElement, so I took a quick look at it and from what I can understand it seems to be unnecessarily using recursion to iterate over the children of ContainerShapes to call EcoreUtil.delete on each individual node. It seems unnecessary because it seems like EcoreUtil.delete is already taking care of the children. So I did an experiment, I deleted all pictogram elements in a large diagram within my application and it took in the neighborhood of 4 1/2 minutes before the operation completed. On the next run I commented out the lines in PeService.deletePictogramElement which iterated over the children of ContainerShapes and also the part that deletes anchors, so it looks like this:
public void deletePictogramElement(PictogramElement pe) {
/*
* if (pe instanceof ContainerShape) { ContainerShape cs =
* (ContainerShape) pe; List<Shape> childList = cs.getChildren();
* List<Shape> l = new ArrayList<Shape>(); for (Shape shape : childList)
* { l.add(shape); } for (Shape shape : l) {
* deletePictogramElement(shape); } } if (pe instanceof AnchorContainer)
* { AnchorContainer ac = (AnchorContainer) pe; Collection<Anchor>
* anchorList = ac.getAnchors(); List<Anchor> l = new
* ArrayList<Anchor>(); for (Anchor anchor : anchorList) {
* l.add(anchor); } for (Anchor anchor : l) {
* deletePictogramElement(anchor); } }
*/
GraphicsAlgorithm graphicsAlgorithm = pe.getGraphicsAlgorithm();
if (graphicsAlgorithm != null) {
EcoreUtil.delete(graphicsAlgorithm, false);
}
PictogramLink linkForPictogramElement = Graphiti.getLinkService().getLinkForPictogramElement(pe);
if (linkForPictogramElement != null) {
EcoreUtil.delete(linkForPictogramElement, false);
}
EcoreUtil.delete(pe, false);
}
Then reran my test case and the operation took 1 minute and 20 seconds this time and the serialization of the diagram looked correct, so it appears everything was deleted correctly. This solution is probably ignoring some reason why this recursion is there to begin with, which is why I bring it up here. I can go ahead and open up a bug report if this is indeed something that looks like it is worth checking out. I should also note that the PictogramElements in my application usually contain a few dozen children, which is probably why this issue is particularly painful for me.
Thanks,
Craig
[Updated on: Thu, 17 May 2012 16:38] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02101 seconds