Movatterモバイル変換


[0]ホーム

URL:


GetTickCount vs. clock for msec resolution

Tim Peterstim.one at home.com
Fri Apr 20 01:38:25 EDT 2001


[Les Schaffer]> 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.GetTickCount is a legacy API; its resolution varies across systems, but isnever better than 10ms, and is as coarse as 55ms on Win9X.Python on Windows uses the QueryPerformanceCounter API for time.clock(),thanks to Mark Hammond.  How good that is (indeed, whether it even exists!)depends on your platform.  On my home box, it updates 1,193,180 times persecond (use QueryPerformanceFrequency to get your magic number -- it willprobably be the same if you're running on a Win9X Pentium).  So ms resolutionis a yawn for it.  BTW, you'll find the hardcoded number 1193180 inwinsound.c too:  this isn't a coincidence <wink>.clock() on Linux returns CPU time, not wall-clock time.  I don't rememberwhat its resolution is, but you won't like it.  time.time() may or may not bebetter for you there (across Unix flavors, it varies from microsecond tofull-second resolution; on Win9X it's something bizarre, *appearing* to be10ms unless you look very carefully and notice it's only updated 18.2 timesper second).In any case, don't mistake resolution for accuracy.  You didn't ask aboutaccuracy <0.5 wink>.for-more-on-that-do-a-google-search-ly y'rs  - tim


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp