Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  threads on linux  (Read 3163 times)
0 Members and 1 Guest are viewing this topic.
Offline stonedyak

Junior Newbie




Java games rock!


« Posted 2002-11-28 13:16:29 »

Hi,
I'm developing a platform game using java 2d. I'm working mainly on windows, but also testing on linux.

Speed is not an issue on windows, since java can use my graphics card - but linux seemed to be a lot slower.

I'm doing rendering on a seperate thread  (a while loop in the run() method), and using thread.sleep(x) to control the speed.

I was getting about 33fps on linux with scrolling and a few sprites moving around. I was sleeping for about 12ms per frame. Then I set the sleep to 0 and I started getting 200fps!! But if I set the sleep to 1 I only get about 50fps.

I assume this is to do with how threading is handled on Linux - is there a better way to control the speed in my game?

Offline pepe

Junior Member




Nothing unreal exists


« Reply #1 - Posted 2002-11-28 14:08:23 »

if 200 fps is slower than windows, can you tell me what is the framerate under windows??

Normally, linux has a millisecond grain for the timer. Window's one is around 10 to 15 ms..
If you want to know your salt, code a loop with 1ms sleeps, and show the currentTimeMillis each time you quit the sleep.
You should have output at the same 'date' for some time. simply see what is the increment when the time changes.

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline stonedyak

Junior Newbie




Java games rock!


« Reply #2 - Posted 2002-11-28 14:39:18 »

Actually I just got home and tried out the code on my windows machine (1ghz with geforce2 mx 32mb) and was rather dissapointed to find i (only?) got 150fps!  - that was with a sleep time of 0 again.

The computer with linux on is one at Uni - it's pretty new (does anyone know how to find out the processor speed/type on Linux?) It must be quite a beast to outperform my computer without any h/w acceleration!

Can anyone think of a reason why there should be such a speed difference between sleeping for 1ms and sleeping for 0ms?


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pepe

Junior Member




Nothing unreal exists


« Reply #3 - Posted 2002-11-28 14:41:43 »

Except a big granularity in timers, nope.

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline Themroc

Junior Member





« Reply #4 - Posted 2002-11-28 16:15:36 »

As pepe said you usually can't sleep for 1ms, the minum amount is system dependant and about 10ms on WinXP.

I have trashed the whole sleep() stuff to get constant frame rates. I now have am anim-controller-class that extends java.util.TimerTask and that is called by a java.util.Timer as often as I want FPS. That works quite OK,not perfect, but it's the most stable I got with a basic JRE in windowed mode (else you can use a HiresTimer form Java3d and busy-wait...)
Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #5 - Posted 2002-11-28 20:22:05 »

Quote
Actually I just got home and tried out the code on my windows machine (1ghz with geforce2 mx 32mb) and was rather dissapointed to find i (only?) got 150fps!  - that was with a sleep time of 0 again.

There are other reasons as to why there could be such a performance difference between systems, not talking about sleep() here.
  • There are some known problems when using jre 1.4.1 with some geForce 2 MX cards. Although I don't think it applies to you since 150fps is not bad anyways. They are working on this. (see the thread on side scrolling, there's a mention there)
  • video memory is normally accessed through AGP. This might slow down graphics in some circumstances. I have a cheap motherboard that uses system RAM for video and, although sharing RAM between CPU and video is generally not optimal, there is no transfer of data through the AGP. This makes my cheap motherboard very fast when writing/reading on 'video' RAM. The same might apply to your linux box.


Seb

Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #6 - Posted 2002-11-28 20:42:04 »

Quote
video memory is normally accessed through AGP. This might slow down graphics in some circumstances. I have a cheap motherboard that uses system RAM for video and, although sharing RAM between CPU and video is generally not optimal, there is no transfer of data through the AGP. This makes my cheap motherboard very fast when writing/reading on 'video' RAM. The same might apply to your linux box.


Actually, I might be partially wroung here. My motherboard might still use AGP circuitry to negotiate the reading/writing on the video part of RAM, which might slow things down a tad. It might even send the data through the bus at 1x, 2x or4x speed.

In any case, this could still apply to your linux box, as it could have a completely different and straight forward architecture. I miss the old Atari ST days, that machine had all of system RAM available to video, working at twice the speed (16MHz!!!) of the CPU, the memory was accesed by both on alternate cycles. So the CPU never had to wait to use RAM. Anybody have any 4GHz DIMMs?

Seb

PD: Me, I didn't mean to piss me off by correcting myself, so don't flame me.

Offline leknor

Junior Member




ROCK!!!


« Reply #7 - Posted 2002-11-28 21:00:52 »

Quote
does anyone know how to find out the processor speed/type on Linux?

To get info on the cpu open a shell and run `more /proc/cpuinfo` There are other intersting things in /proc too, take a look around.

`lspci` is a nice command too for info about what is on the pci bus.
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #8 - Posted 2002-11-30 05:29:18 »

Note that your fps numbers may be off on *nux unless you do Toolkit.sync(); after each frame. X is asynchrous, so w/o the sync you're really measuring the speed with which you can issue the commands to the X server.
Offline stonedyak

Junior Newbie




Java games rock!


« Reply #9 - Posted 2002-11-30 08:23:27 »

Quote
Note that your fps numbers may be off on *nux unless you do Toolkit.sync(); after each frame.


Thanks, I'll try that. However, judging visually, it does seem to be going faster on linux than it does on my windows machine.

Does toolkit.sync() make any difference on windows? I'm using a buffer strategy to do my graphics in both full screen and windowed mode. I've tried inserting it before i draw my graphics, before I call bufferstrategy.show(), and after it - it's still going at full throttle!

Quote
To get info on the cpu open a shell and run `more /proc/cpuinfo


I tried this -  the linux machine I'm testing on appears to be an Athon 1.5GHz 1800+ with 512 meg of ram.


One other question. Does anyone know why in full screen exclusive mode, the framerate is limited to the refresh rate of the screen mode I'm in, whilst in windowed mode, it just goes as fast as it possibly can? (with tearing of course)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #10 - Posted 2002-12-01 07:13:31 »

If you're using a flip buffer strategy on windows in fullscreen mode, you're actually bound to your monitor refresh rate, so calling Toolkit.sync probably won't make any difference.

It could make a difference in windowed mode, though.
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.

BurntPizza (12 views)
2014-09-19 03:14:18

Dwinin (30 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!