Optimization with java exception

Started by Kokoni, September 21, 2005, 14:34:58

Previous topic - Next topic

Kokoni

Hello all,

I'm currently using the lib log4j (log API) for my lwjgl program. I would like to catch exceptions and after logging it with log4j.

My question is : do you think the java exception mechanisme (I mean try catch block, and throw(s)) is not too much time consumer for an opengl application ?

Thanks in advance.

princec

Exceptions are exceptional. They should never occur. If they do, it doesn't really matter if your framerate drops, because you are probably in some kind of panic by then anyway.

Cas :)

Kokoni

We are OK for the treatment, the catch block.

But concerning to "try{... }" the code anywhere,  for exemple :

foo.computeVariance();


and

try {
foo.computeVariance();
}
catch(FooException fe) {
// logging etc ...
}



Is the execution of foo.computeVariance(); in the first version is more quick than the second ? I guess, but is it critical for an opengl application ?

Matzon

a try/catch is not significantly slower, until an exception occurs.

Kokoni

OK thanks, I was hesitant to use java exception.

So I'm going to build a fortress with my code now :lol: