Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Time functions:

Author: Steffen Jakob

Date: 10:27:49 09/25/99

Go up one level in this thread


On September 24, 1999 at 10:19:45, Robert Hyatt wrote:

>On September 24, 1999 at 07:50:47, GBes wrote:
>
>>you can use clock( ) for this.
>>
>>clock_t start,finish;
>>
>>start = clock();
>>// ...
>>finish = clock();
>>double difference = (double)(finish-start)/CLOCKS_PER_SECOND;
>
>
>clock() is bad.  It returns processor time, and not wall-clock time.  If
>something else runs with you, you will use more time than expected because
>your cpu time doesn't increase linearly with elapsed time.

clock() is only bad for real games. But it is good for testing because you can
compare the result of two versions much better.

I use both, clock() and gettimeofday() in Hossa. I have a special command "tm"
for "time mode" which I can call e.g. like "tm clock" to tell Hossa which
function he should use.

>For unix, I use gettimeofday() which returns a very accurate wall-clock time
>accurate to microseconds if you want...

Best wishes,
Steffen.



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.