Testing Performance [SOLVED]

Hi all,

I am at a point in my game where I want to optimize it for the best performance possible, but I am using an FPSAnimator, and as far as I can tell, the only thing I can do with it is start, stop, and isAnimating, none of which help me to determine the efficiency of the game. I am running it on a pretty fast system so a poorly implemented algorithm doesn’t necessarily slow it down enough for me to see a difference. Is there a way to use the animator to determine the duration the thread is sleeping (or any other comparable benchmark) or am I going to need to use Thread.sleep and do the tests myself?

Thanks

I think most games just use FPS. At the beginning of your loop do this:

long nanoTime = System.nanoTime();

Then at the end of your loop do this:

nanoTime = System.nanoTime() - nanoTime;
System.out.println("Frames Per Nanoseconds: " + nanoTime);
System.out.println("Frames Per Seconds: " + ((double)nanoTime) / 1000000000.0);

Or you can use System.currentTimeMillis() and divide by 1000. Also, you could use Animator instead of FPSAnimator and call animator.setRunAsFastAsPossible(true). Of course, by doing this, everything is going to go extremely fast and probably make the game unplayable, but you can just use it for testing purposes.

Probably the best way to see how well your game is running is to run it on multiple machines. It might be great on your computer…but on Bob’s computer it’s crap.

Poor Bob…

System.out.println("Frames Per Nanoseconds: " + nanoTime);

:persecutioncomplex:

Damn, I want that system.

Ah, I see, thanks