Optimizing Groovy Performance
<p>I'm working on groovy code perfomance optimization. I've used jvisualvm to connect to running applicaton and gather CPU samples. Samples say that <em>org.codehaus.groovy.reflection.CachedMethod.inkove</em> takes the most CPU time. I don't see any other application methods in samples.</p>

<p>What is the right way to dig into <em>CachedMethod.invoke</em> and understand what code lines really give perfomance penalties?</p>

<p>Thanks.</p>

<p><strong>UPD</strong>:
I do use <strong>Indy</strong>, it didn't help me. </p>

<p>I didn't try to introduce <em>@CompileStatic</em> since I want to find my bottlenecks before rewriting groovy to java.</p>

<p>My problem a bit similar to this thread: <a href="http://groovy.329449.n5.nabble.com/Call-site-caching-faster-than-invokedynamic-tp5721659p5721674.html" rel="nofollow">Call site caching faster than invokedynamic?</a></p>

<p>I have a code that dynamically composes groovy script. Script template looks this way:</p>

<pre><code>def evaluateExpression(Map context){
    def user = context.user
    %s
}
</code></pre>

<p>where <strong>%s</strong> replaced with </p>

<pre><code>user.attr1 == '1' || user.attr2 == '2' || user.attr3 = '3'
</code></pre>

<p>There is a set (20 in total) of replacements have taken from Databases. 
The code gets replacements from DB, creates GroovyScript and evaluates it.
I suppose the bottleneck is in the script execution. What is the right way to fix it?</p>