|
-
May 25th, 2005, 07:04 PM
#5
Re: clock ticks
GetTickCount is inaccurate. It's especially inaccurate on the 9x series (updating only 13 times a second or so).
clock() is just as inaccurate. You have no guarantee at all about the actual resolution of this call. POSIX demands that CLOCKS_PER_SEC be 1000000, but nothing demands that the status is updated that often. CLK_TCK is equivalent to CLOCKS_PER_SEC, but outdated and considered obsolete.
clock() is also unsafe, because it wraps around a lot. On a POSIX-compliant system with a 32-bit clock_t, it wraps every 72 minutes, which is a lot. Get such a wrap into your measurement period and you get confusing results.
clock() is also unpredictable. OSs differ in what they include in the measurement, e.g. some unices include the processor time of child processes, while others don't.
If you're measuring real time and have no need for portability, I recommend queryPerformanceCounter() on Windows. There's also some calls for getting the actual processor usage that are better than clock().
On Linux, you can use the times() function to get more accurate info about where and how a process spends its time.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|