From: Dennis Ranke Date: 2005-11-11T18:17:14+09:00 Subject: Re: Accurate Timing in ruby Kero wrote: >> Believe it or not, I'm attempting to make an action-driven game with ruby >> Is there a way to get the time in milliseconds since the program start >> ed, or something similar? I've tried using Time.now.to_f, but all too of >> ten that value will be the same in two consecutive update calls, causing >> jumps in motion and "infinite" fps readings. > > [...] > > I fear what you see is not Ruby's fault, but your hardware/OS clock. > 1) your hardware is so fast that the consecutive calls have no > significant distinguishing bits left (I have 2 or 3 bits left on 700 > MHz; you may need nanoseconds instead of microseconds) > 2) your OS is not updating its system clock often enough > > Even though windows has nasty habits when updating time to a central > server, I do not think it suffers from 2) In my experience it does: irb(main):006:0> a=Time.now;while Time.now==a;end;Time.now-a => 0.01 ie. Time.now only gives you the time in centiseconds. I would recommend the initial poster to use one of the SDL bindings, if possible, which include methods to query the time much more accurately. Dennis