Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Performance Problem on OSX  (Read 813 times)
0 Members and 1 Guest are viewing this topic.
Offline frizkie

Junior Newbie





« Posted 2012-04-18 20:45:42 »

Hi, I've got a simple 2D game going and it works fine on Windows. I've tried on two machines, both with i5 processors, one quad core, one dual core. They both run at the full 60 frames per second, and everything is smooth. I had someone I know try it on their mac (2010 MBP), and it only manages 5-10 frames per second, and everything is super laggy - the player jumps around, and the game freaks out in general. I also tried it on a 2006 MBP, and I had the exact same results. The 2006 is a dual core, and the 2010 is also dual-core. Here's my code, I don't know if there's something about the hardware that makes it not run, and that my game is just terribly optimized, or if it's the fault of OSX and it's Java.

You can download a compiled JAR and source code here, it's a bit long to post in this thread. Make sure the DATA folder is in the same directory as the JAR when you run it.
http://dl.dropbox.com/u/6059990/code.zip
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2012-04-19 00:25:03 »

I tried running it on my i5 MBP and also saw very low performance.

Taking a look into your code, my best bet is that your run loop is buggy and is sleeping way longer than expected.  I replaced it with a simple update/render/sleep loop fixed to 60fps and the FPS counter claimed it was running at 60fps.

Unfortunately, all of the animations were still very slow and laggy, but I started looking into your code and it looks like you have strange time tracking throughout your project.

My best guess is that's what is causing your problem.  OS's report different accuracies with their timer so it's possible that Windows masked these problems.  Similarly, Thread.yield() may behave differently.  I would recommend using as simple a loop as possible, relying on sleep only instead of yield+sleep, and perform your animations based on a standardized delta time based on seconds.

Offline frizkie

Junior Newbie





« Reply #2 - Posted 2012-04-19 02:37:08 »

Thanks for trying it out. It's actually heavily-altered source from a different 2D game, but the odd time keeping method is the way the original writer made game tiles (like the water animation) change each second. Other than that, I use nanoTime exclusively.

I'll look into why it's sleeping so long.

EDIT:

I had a friend try it, and he's running:
2GB Ram
Dual Core 2.1GHz AMD processor
Integrated graphics

It runs at about 35 frames per second, leading me to believe that his computer isn't powerful enough to do some calculations I'm running. I figured that my code is pretty simple, and that a game should have no problem rendering it, but apparently this is not the case.

Is it just terribly optimized code that is causing the problem?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (7 views)
2014-07-29 18:09:19

Riven (5 views)
2014-07-29 18:08:52

Dwinin (8 views)
2014-07-29 10:59:34

E.R. Fleming (24 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!