Skip to main content

Issue on Linux

8 replies [Last post]
dcomsa
Offline
Joined: 2007-05-29
Points: 0

Hi everyone,

I'm trying to develop an application using TimingFramework but I get very low frame rates. For instance, on an 1 sec animation I get 11 frames (calls to timingEvent() ).

I have also run ExternalTimer from the examples, and here I get some strange results also. Here are the results:

resolution = 71.42857( numEvents: 14)
resolution = 0.5509642( numEvents: 1815)
resolution = 90.90909( numEvents: 11)

The only modification I've made was adding the numEvents field to the System.out.

So, am I doing something wrong, or there is a problem on Linux platforms.

Br,
Daniel.

P.S. I'm running Ubuntu Linux 7.04, on an Intel Pentium M @ 1.73 with 741 MB of RAM.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chet
Offline
Joined: 2003-08-07
Points: 0

Daniel,

No idea how timers are handled on Linux or your hardware platform, although I suspect there's something else at work here. Changing to 5.0 should not have had an effect on it (as one of the replies indicated).

What's happening in the test is that the resolution is set to the default (which happens to be 20), to 0, and then to 20. On my Windows XP box, this gives me results of:

resolution = 29.411764
resolution = 0.698812
resolution = 30.30303

From prior testing, I know that the Swing timer has a resolution of ~16 ms, so a 'resolution' of 20 is equivalent to a resolution of ~32, which makes the first and last results sensible.

On your system, it looks like a much lower res timer, where setting a resolution of 20 resulted in a real resolution of 71-90. But the fact that the first and last results are so different indicates (to me) that there's something else going on. Maybe there was other system load that made the timer unresponsive?

Chet.

dcomsa
Offline
Joined: 2007-05-29
Points: 0

Hi Chet,

Indeed, the switch to 5.0 does no good. It must have been my imagination (and my desire to see it working normally).

Another think I can say, is that there wasn't an heavy load on my system when I run the tests. And I did run it several times (also a few minutes ago; same results). I've noticed that on XP it runs normal, but I'm curious why it doesn't do so also on Linux.

"But the fact that the first and last results are so different indicates (to me) that there's something else going on" - as I've seen in the source code, the first result was by using default timer, and the last was by using a custom (external) timer.

What can I say, I'll dig on it more when I'll have some time. Right now I'm concerned on getting my job done, knowing that it runs well on Windows. After that, I'll have a look on it's behavior on Linux.

I appreciate your reply, and I hope I can give you more info on this matter in the future.

Thanks,
Daniel.

chet
Offline
Joined: 2003-08-07
Points: 0

Whoa - it's apparently been too long since I wrote this code and had forgotten that my 'external timer' used a different mechanism for the callbacks. In the case of the default timer, we use the Swing timer with a resolution of 20 ms. In the case of the external timer, we simply sleep between callbacks for the specified resolution (20 ms, in this case). These work out to be the same on my system because the resolution of the two mechanisms (the Swing timer and Thread.sleep()) is the same on my system. It could be that these mechanisms differ on other systems, such as yours, and that Thread.sleep() has a different resolution.

I have a battery of tests that I created for a section on Resolution in the upcoming book - I wonder what your system would have to report for the different sleeping/timing mechanisms (sorry, the demos aren't posted yet, but I expect they will be in the next few weeks). In the meantime, you could write some simple tests of your own to time the resolution of the different mechanisms.

It makes more sense that you still have the same behavior on 5.0. I suspect that it is some system-specific situation, where the native timers that Java depends upon simply have a higher resolution...

Chet.

dcomsa
Offline
Joined: 2007-05-29
Points: 0

Well, as I've said, I'm forced to leave this matter for later, knowing that it behaves properly on Windows. The good thing, I guess, is that as far as I can see, the solution would be to implement a custom timer. Who knows, perhaps the demos will be out by the time I'll get back on this issue, and I could run the tests you've mentioned.

Btw, when will the book be out? And will it be available for purchase online?

Daniel.

chet
Offline
Joined: 2003-08-07
Points: 0

Before opting for the external timer, you might play around with different resolution values with the built-in timer; it could be that smaller resolution values than the default will give you a better result...

The book is currently slated for mid-August. The publisher expressed some hope that we could pull it into July, but I'll believe it when I'm holding the physical book... In the meantime, the "rough cut" is currently available online on Safari. I believe they'll be rev'ing the online version it to be the final text when it's all done, but I don't know for sure.

rah003
Offline
Joined: 2004-05-26
Points: 0

Hi Daniel,

I'm also running on Feisty although on different hw (AMD 64 bit) and timingFramework works just fine. It might be rather configuration issue then anything else.

Jan

dcomsa
Offline
Joined: 2007-05-29
Points: 0

Hi Jan,

Thank you for your reply. I think the problem is with the java version. I was running 1.6 until I needed to show my work to somewone who was running 1.5. After setting the "Source Level" to 1.5 in NetBeans project, it started woring on my machine also.

Daniel.

rah003
Offline
Joined: 2004-05-26
Points: 0

> Hi Jan,
>
> Thank you for your reply. I think the problem is with
> the java version. I was running 1.6 until I needed to
> show my work to somewone who was running 1.5. After
> setting the "Source Level" to 1.5 in NetBeans
> project, it started woring on my machine also.
>
> Daniel.

I have it working for both 5 and 6. But I seem to remember someone mentioned problem with installing 6 on Ubuntu and solution was to get the installer and reinstall. Give it a try when you get time.