Author: Alexander Kure
Date: 06:16:59 08/08/00
Go up one level in this thread
On August 08, 2000 at 08:09:22, Vincent Diepeveen wrote:
>On August 08, 2000 at 05:19:39, Alexander Kure wrote:
>
>>Hi James,
>>
>>#include <time.h>
>>
>>clock_t start = clock();
>>
>>// do what ever you want to measure
>>
>>clock_t stop = clock() - start;
>>
>>printf("Elapsed time in seconds: %.2f", (double) stop / CLOCKS_PER_SEC");
>>
>>Function clock() returns the number of clock ticks of elapsed processor time for
>>the current process.
>
>Under windows clock() is nice.
>
>However if you use a win32 interface then setting a timer
>will give times using gettickcount() which is more accurate as clock()
>is. Most likely under windows clock() is enough.
>
>Under linux DO NOT USE clock(), as it gives overflow each 72 minutes.
>
>>Greetings
>>Alex
According to Win32 documentation GetTickCount() produces an overflow after 49.7
days when run continously ;-)
However my limited understanding is that clock() only counts the ticks the
current process has used, so when you have other processes running that also
consume significant cpu time they would not influence the count() result.
But if you use GetTickCount() the return value is dependant on the time other
processes consume.
By the way clock() is platform independent and available in every c/c++ library.
Greetings Alex
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.