Marc Müller Marc Müller - 1 year ago 97
Java Question

Java graphics performance

I was programming a simple game and wanted to display it via the Java Graphics + Swing API. It felt a little slow, of course, so I measured how long it took to repaint, which was around 32ms. Then I read about accelerated Java graphics and used the method described here: Space Invaders

However, somehow this is even slower. It now takes around 98ms to redraw. Why is that?

Note that I am aware of libraries like LWGL and JOGL, but I don't want to use a full-blown OpenGL wrapper for such a graphically simple game.

Answer Source
  1. Read this about timers
  2. Use an always sleeping thread in the background to lower the system interrupt rate to get much more precise timers!
  3. You can take a look at my code in here
  4. A small game I've created can be found here

    long renderStart = System.nanoTime()
    // render stuff here
    long renderTime = (System.nanoTime() - renderStart) / 1000000;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download