Java: Netbeans debug session is faster than normal startup

I am doing Braid in Netbeans 6.7.1.

Computer specification:

Windows 7
Running processes: 46
Running threads: +/- 650
NVidia GeForce 9200M GS
Intel Core 2 Duo CPU P8400 @ 2.26Ghz

      


Game spec with normal run:

Memory: between 80 MB and 110 MB
CPU: between 9% and 20%
CPU when time rewinding: 90%

      

Same values ​​for a debug session , except when I rewind time: CPU: 20%.

Is there a reason? Is there a way to achieve the same performance in normal operation.

This is my repainting code:

 @Override
 public void repaint()
 {
     BufferStrategy bs = getBufferStrategy(); // numBuffers: 4
     Graphics g = bs.getDrawGraphics();
     g.setColor(Color.BLACK);
     g.fillRect(-1, -1, 2000, 2000);
     gamePanel.paint(g.create(x, y, gameDim.width, gameDim.height));
     bs.show();
     g.dispose();
     Toolkit.getDefaultToolkit().sync();
     update(g);
 }

      

The game runs in full screen mode (unecorated + frame.size = screensize)

Martijn

+2


source to share


2 answers


What structure are you using? Or did you write it yourself? In the latter case, are you using System.currentTimeMillis () or System.nanoTime () to limit the FPS?

Debugmode can change the resolution of the OS interrupt rate in Windows and hence change the resolution of System.currentTimeMillis () too.



I had a similar case where my game ran faster when using VisualVM. Using System.nanoTime () instead of System.currentTimeMillis () to calculate the value for Thread.sleep () has been fixed.

You can read more about this topic here: http://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks

+2


source


The method is repaint()

cheap because multiple requests are merged before processing. I am assuming that under the debugger more replications are merged into real calls paint()

.



Try to keep a counter that is updated on every call paint()

or paintComponent()

. If I'm right, you should see fewer calls when running under the debugger.

+1


source







All Articles