GetTickCount vs. clock for msec resolution
Les Schaffer
schaffer at optonline.net
Thu Apr 19 23:42:42 EDT 2001
i am talking to some hardware, needing to resolve 10's-100's of msec
of time. So I started playing around with the clock and GetTickCount
functions under win32 to check for finer time resolution.
See code below. timimg results for win2k at:
http://folks.astrian.net/godzilla/ticks.html
GetTickCount has some funniness in its behavior.
i'm good and stickin with clock for now. But I am curious to hear
other people's observations about msec time resolution or possibly
even smaller, particularly on winXX and linux.
les 'time-has-come-tudayyy' schaffer
=========================
from time import clock, sleep
from win32api import GetTickCount
def _yawn( sec ):
now = clock()
while (clock() - now) < sec: pass
div = '\n========\n'
def testTick( sleepyTimeTime ):
print div, 'SleepyTimeTime = ', sleepyTimeTime*1000, div,
for i in (0,1,2):
x = clock()
_yawn(sleepyTimeTime)
y = clock()
print 'delta(clock) = ', (y-x)*1000
x = GetTickCount()
_yawn(sleepyTimeTime)
y = GetTickCount()
print 'delta(GetTickCount) = ', y - x
print div
testTick(0.0001)
testTick(0.001)
testTick(0.01)
testTick(0.1)
testTick(1)
More information about the Python-list
mailing list