From: Harold Hausman Date: 2005-11-12T03:50:17+09:00 Subject: Re: Accurate Timing in ruby ------=_Part_20509_1834741.1131735013093 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline That looks legit, Wheres that from? -Harold On 11/11/05, Kroeger, Simon (ext) wrote: > > does that help? > > ------------------------------------------------------------------------ > -- > > require "Win32API" > > QueryPerformanceCounter =3D Win32API.new("kernel32", > "QueryPerformanceCounter", 'P', 'I') > QueryPerformanceFrequency =3D Win32API.new("kernel32", > "QueryPerformanceFrequency", 'P', 'I') > > def get_ticks > tick =3D ' ' * 8 > get_ticks =3D QueryPerformanceCounter.call(tick) > tick.unpack('q')[0] > end > > def get_freq > freq =3D ' ' * 8 > get_freq =3D QueryPerformanceFrequency.call(freq) > freq.unpack('q')[0] > end > > ticks1 =3D get_ticks > sleep 1.5 > ticks2 =3D get_ticks > > p (ticks2 - ticks1).to_f / (get_freq) > > ------------------------------------------------------------------------ > -- > > cheers > > Simon > > > -----Original Message----- > > From: Harold Hausman [mailto:hhausman@gmail.com] > > Sent: Friday, November 11, 2005 5:04 PM > > To: ruby-talk ML > > Subject: Re: Accurate Timing in ruby > > > > Silly Windows. > > I haven't looked at the source but it sounds like it might be using > > ::GetTickCount(), if thats the case it could probably be > > refactored to use > > ::QueryPerformanceCounter() which is a significantly higher resolution > > timer. Of course, then questions of 9x compatibility come up. > > The idea of using the SDL wrapper for making a game is > > probably a good one > > though. > > -Harold > > > > On 11/11/05, Robert McGovern wrote: > > > > > > > > So my PDA is more accurate than your machine (what OS is that?) > > > > > > > > Windows XP. > > > > I think I got better accuracy on my iBook as well, so > > it's probably a > > > > limitation of the OS functions ruby uses to retreive the time on > > > Windows. > > > > > > Mmm, I think your right ... my XP box reports: > > > > > > irb(main):001:0> a=3DTime.now;while Time.now=3D=3Da;end;Time.now-a > > > =3D> 0.016 > > > > > > for a Athlon 2800. > > > > > > > > > > ------=_Part_20509_1834741.1131735013093--