Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Dabbabas clock has a ghost at midnight!

Author: Don Dailey

Date: 10:17:08 05/31/98

Go up one level in this thread


On May 31, 1998 at 12:13:28, Jens Baek Nielsen wrote:

>
>My chessprogram Dabbaba uses this code to get the time:
>
>double get_the_time()
>// returns the number of 1/100 seconds since the program started
>{return (double)(100*(clock())/CLK_TCK);}
>
>It works fine except at midnight, where strange numbers suddenly appears
>- suddenly white has used more than 8 million seconds etc.!

I don't think clock() has anything to do with midnight.  You might
be just getting overflow if you run it too long.

By the way, Bob is right about what clock() does.  You may not want
to measure cpu time because your program will not keep correct time
when other processes are happening on your machine.  You need to
use "wall clock time."

This routine works on a unix system.  It may also work on other
OS's.

typedef  unsigned long long u64;

/* return an absolute wall time counter in milliseconds  */
static u64 wall_time()
{
  struct timeval t;
  struct timezone tz;
  u64 result;

  gettimeofday(&t,&tz);

  result = 1000 * (u64) t.tv_sec;
  result += ((u64) t.tv_usec)/1000;

  return(result);
}



>
>Is it only me who has encountered this problem?
>Is there a better way to measure the time?
>
>I consider to estimate the time from the number of nodes searched at
>this midnightevent, but it is rather silly code to have in your program.
>
>I use a Borland Turbo C++ 3.0 compiler.
>
>Greetings Jens



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.