LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Kokoni on September 21, 2005, 14:34:58

Title: Optimization with java exception
Post by: Kokoni on September 21, 2005, 14:34:58
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.
Title: Optimization with java exception
Post by: princec on September 21, 2005, 14:54:10
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 :)
Title: Optimization with java exception
Post by: Kokoni on September 22, 2005, 05:44:32
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 ?
Title: Optimization with java exception
Post by: Matzon on September 22, 2005, 06:14:26
a try/catch is not significantly slower, until an exception occurs.
Title: Optimization with java exception
Post by: Kokoni on September 22, 2005, 08:21:04
OK thanks, I was hesitant to use java exception.

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