Skip to content
  Kermeta  

Optimization tips of kermeta code

Document Actions

Here is a list of known optimizations that you can apply to your kermeta code



Tip 1 : Saving model

When saving a resource (containing your model elements), Kermeta will check all the elements that it may be connected to. Ie. it will check all the element of all the resources for your repository.

You may speed up a little bit the save process by removing useless resources from the repository. For example, you don't need to check your input resources will saving your output resources if you have no link between them.

Tip 2 : Using large collection

Sometimes, you may need to build collections with many elements. If you use a Set, the performance will probably be bad. This is due to the check of unicity of the elements in the Set. If possible you can avoid this computation overhead if your algorithm accept to use a Bag instead of a Set.

Tip 3 : Building large String

Like in java, Kermeta "+" is not very efficient when building large String. So the framework introduce a StringBuffer which has better performances.

Tip 4 : Implementing a fast internal traceability

Sometimes you need to trace the elements created from a given source element. If this trace is intended only for internal purpose (ie. you do not plan to serialize it directly) then you can take advantage of the weaving mecanism. You simply have to add a reference in the input elements that point to the target element. This solution is elegant and even faster that a Hashtable !