groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Optimizing groovy performace
Date Mon, 11 Apr 2016 09:30:28 GMT
On 10.04.2016 20:52, Serega Sheypak wrote:
>  > org.codehaus.groovy.vmplugin.v7.Selector$MethodSelector.doCallSiteTargetSet
> I see this method after switching to indy version with invkoedynamic
>
>>  That is a hint, that you have a lot of invalid callsites going on
> What does it mean? What can I do in order fix it?
>
>>Those are all strings?
> Script template is:
>
> |defevaluateExpression(Mapcontext){defuser =context.user %s }|
>
> dynamically substituted expression could contain anything
>
> |user.attr1 =='1'||user.attr2 =='2'||user.attr3 ='3'|
>
> user object holds info about a user doing something online. attr1,
> attr2, attr3 could returns various types. Sometimes they return object
> and I override returned object equals method.

you wrote there are 20 such replacement cases... executing 20 scripts is 
hardly a problem, so it must happen in a loop... do you reuse the 
scripts, or do you make a new script each time? Because if you do them 
new each time, you have of course never ever an caching going on... but 
then the compiler should appear in your measurement as bad factor as 
well actually.

To give an advice I have to understand your setup better first

> For example, 'user' object has method:
> LastPage getLastPage(){
>          def attr = getLatestAttribute(PAGE)
>          if(attr){
>              lastPage = attr.value
>          }
>          new LastPage(lastPage: lastPage)
>      }
>
> then you can write expression:
> user.lastPage == 'somePageRegEx/.*' when you want to get true if user
> last page mathes provided regex.
>
> Here is LastPage impl:
> class LastPage {
>      String lastPage
>
>      @Override
>      String toString(){
>          lastPage
>      }
>
>      @Override
>      int hashCode(){
>          1
>      }
>
>      @Override
>      boolean equals(Object object){
>          if(object == null || !(object instanceof String || object
> instanceof LastPage)){
>              return false
>          }
>          if(object instanceof LastPage){
>              lastPage.equals(object.lastPage)
>          }
>          else{
>              Pattern pattern = Pattern.compile((String)object)
>              lastPage ==~ pattern
>          }
>      }
> }

and pattern compilation here does not have a negative factor in your 
measurement?

bye Jochen

Mime
View raw message