does that help?
···
------------------------------------------------------------------------
--
require "Win32API"
QueryPerformanceCounter = Win32API.new("kernel32",
"QueryPerformanceCounter", 'P', 'I')
QueryPerformanceFrequency = Win32API.new("kernel32",
"QueryPerformanceFrequency", 'P', 'I')
def get_ticks
tick = ' ' * 8
get_ticks = QueryPerformanceCounter.call(tick)
tick.unpack('q')[0]
end
def get_freq
freq = ' ' * 8
get_freq = QueryPerformanceFrequency.call(freq)
freq.unpack('q')[0]
end
ticks1 = get_ticks
sleep 1.5
ticks2 = 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 rubySilly 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.
-HaroldOn 11/11/05, Robert McGovern <robert.mcgovern@gmail.com> 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=Time.now;while Time.now==a;end;Time.now-a
> => 0.016
>
> for a Athlon 2800.
>
>