This is my first post on this forum, I have about 6 months of experience working with Java in general and about 1 month of programming Java GUI (Swing), so consider me as a Java newbie.
I started developing a simple 2D shooter game with Java swing as a hobby. I am using Java 1.6.0_65 with Mac OS X 10.6.8, a 2.4GHz MacBook Pro with Intel Core 2 Duo (Spring 2010 model), and the display card is NVIDIA GeForce 320M.
In my drawing method, I draw about 30-50 rectangles using the Swing method drawRect(), 32 * 32 pixels in size, few are 7 * 7 pixels in size, and smaller ones are filled with fillRect. I call the method paintComponent()50 times / sec from the timer callback.
To get an idea of how fast / slow the picture is, I added some measurement code to record the start and end times of the method paintComponent()and calculate the average duration using the System.nanoTime () method.
The average runtime for one paintComponent()is around 3000 usec in OS X 10.6.
I also run the same code in pair for a PC running Windows 7 (Sony Vaio laptop, AMD 2.x GHz dual-core processor and HP laptop, Intel quad-core 2.x GHz processor, I don’t remember all the details now). On Windows machines, the average execution time was only about 100, which is about 30% faster!
What can explain such a big difference? Can it System.nanoTime()work with different resolutions between Windows 7 and OS X or does it really look slower in OS X?
, , GUI ( , ..), 50 - 100 us , , , System.nanoTime() , OS X?
: - xCode Eclipse, , , , : http://www.java-gaming.org/topics/swing-performance-os-x-10-6-vs-windows-7/31654/view.html.
Mac , 1400 - 1800 / .