Performance implication of using xtextResource.getContents().get(0) [message #1817917] |
Tue, 03 December 2019 06:03 |
Neeraj Bhusare Messages: 177 Registered: July 2009 Location: Canada |
Senior Member |
|
|
Hi All,
While profiling a piece of code, I replaced the call to
xtextResource.getContents().get(0) with xtextResource.getParseResult().getRootASTElement()
After making the change, I saw a drastic reduction in the time taken by the the method that contained in the above code.
The code `xtextResource.getContents().get(0)`, internally invokes the associated JVMModelInferrer which took most of the method execution time. My objective was to get hold of the root-object, at the same time avoid the call to the JVMModelInferrer, and the above change seems to fit the bill.
Is this a recommended thing to do? Can someone please confirm?
Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
|
|
|
Re: Performance implication of using xtextResource.getContents().get(0) [message #1817918 is a reply to message #1817917] |
Tue, 03 December 2019 06:56 |
|
The DerivedStateAwareResource will install the derived state, and in your case use the inferrer, when invoking getContents(). If you do not need to install the inferred JVM model, then this will be faster, sure. But why do you have an Xbase based language then?
I can't give a recommendation on that without knowing the real use case in detail. So as long as it works for you, why not? The general recommendation can only be to go the "normal" way, as it is safe in regards of the expected state of the resources.
|
|
|
|
Powered by
FUDForum. Page generated in 1.04527 seconds