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