Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: blue5teel on November 25, 2010, 01:49:21 am
-
Hello community,
currently i am making an import add-in for EA.
The objects are stored in an xml file.
For each object i generate an EA.Element and make some updates and refreshes.
EA.Element subElement = constructElement(element, subReq);
subElement.Update();
subElement.Refresh();
I generate some tagged values too and call update.
Then i update the package containing the element.
Furthermore i make a diagram and a diagramobject for each element. Some updates and refreshes following.
It takes decades to import 1000 objects.
Are there any recommendations for using refresh and update. Can i save some time not calling them? Or are there other bottlenecks?
-
Hi,
I think you can go without the refresh operation for each element. You can do a Repository.RefreshModelView() after you finished importing everything.
Some other options you can try to increase performance are:
- Repository.BatchAppend
- Repository.EnableCache
- Repository.EnableUIUpdates
Without further details of your code I can't really do any more recommendations.
What you could do is look at the excel importer (http://community.sparxsystems.com/resources/scripts/simple-vba-excel-ea-importer) I published on the community site. I had some performance issues there too, and I was able to increase the speed quite a lot. IIRC it imports 10.000 lines in a matter of minutes, but I would have to test it to be sure.
Geert
-
Thx Mister Bellekens,
i kicked the refresh operations and got some improvement.
1000 elements take 7 minutes now.
BatchAppend and EnableUIUpdate did just some minor improvements (seconds). EnableCache seems to even increase the computation time.
But i have to do some more research.
thx.
-
Ok.
I made a big mistake. :-[
Everytime i made an element or diagram update i updated their parent package too. I removed those updates and it showed that these updates are not neccessary.
I decreased the computation time from 7 minutes to 40 seconds!
Sorry :-[
-
Thx Mister Bellekens
Whoa, "Mister Bellekens" is my dad, just "Geert" is enough ;)
(I know, must be difficult for someone who addresses his colleagues with Herr/Frau <lastname>)
In fact, when I was working on the performance issues with my addins the VS Performance Analysis helped a lot. It also showed that most of the processing time was spent doing countless database calls.
So the trick to is avoid database calls as much as possible.
On of the really weird things with the API is that is even does one or more database calls while iterating an EA.Collection. So the trick is to only iterate a certain collection one, and as soon as you have an EA.Element, EA.Attribute,... store it in something sensible, like a "real" Collection (List<> or something like that).
Geert
-
I decreased the computation time from 7 minutes to 40 seconds!
That quite an improvement.
Now put the package.updates back an install it like that. After the users start complaining you can be the hero by improving the performance by this much ;D
Geert
-
Lol ;D
Before i can make those improvements they will kill me for my incompetence. ;)