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 Sun, 17 Apr 2016 14:46:47 GMT
On 17.04.2016 14:41, Serega Sheypak wrote:
> Ok
> try{
>      mySuperHeavyMethod()
> }catch(){}
>
> runs 10 times slower that without try/catch...
> why :)

Well... ever tried something like this?

boolean booleanThatIsNeverTrue = false
public void aMethod() {
   if (booleanThatIsNeverTrue) { foo() }
   bar()
}

volatile boolean booleanThatIsNeverTrue = false
public void aMethod() {
   if (booleanThatIsNeverTrue) { foo() }
   bar()
}

They behave very different in that the later version is almost not 
optimized by hotpot - while in the first case you get almost zero 
overhead for aMethod and get almost only the the readings from bar. the 
first version can be inlined, the second one not. I did not investigate 
how these things behave with try-catch, but I see it very possible, that 
there are similar poblems.

bye Jochen


Mime
View raw message