Author: Inmann Werner
Date: 03:41:15 06/10/98
Go up one level in this thread
On June 10, 1998 at 03:23:05, Alessandro Damiani wrote:
>Hi all!
>
>Currently I am converting my program Fortress from Oberon2 to C (not
>because I prefer C).
>
>On my old Amiga I used an interrupt (frequency: 50Hz) to determine if
>the search time is over:
>
> VAR
> TimerOn * : BOOLEAN;
> ticks * : INTEGER;
> Timer * : LONGINT;
> TimeUsed * : LONGINT;
>
> PROCEDURE TimerInt;
> (* $SaveRegs+ *)
> BEGIN
> IF TimerOn THEN
> IF ticks>0 THEN
> DEC(ticks)
> ELSE
> ticks:= 50;
> IF Timer>0 THEN DEC(Timer) END;
> IF TimeUsed<MAX(LONGINT) THEN
> INC(TimeUsed)
> END
> END
> END
> END TimerInt;
>
>Before the search is started the variable Timer is set to the time limit
>and TimeUsed to 0. To determine if the time is over, one has only to
>test if Timer is equal to 0. This is done in every node of the 'tree'.
>
>I don`t like to read the clock after some nodes. So I want to use such a
>timer in C. How can it be done on a SUN and on a PC?
>
>thanks
>
>Alessandro
Hello Alessandro
My program also is in c.
In most C Compilers, there is a function called ftime
You have to include some file like "time.h" (see compiler)
program
#include <stdio.h>
#include <time.h>
#include <timeb.h>
main()
{
struct timeb tt;
long mytime;
ftime(&tt);
mytime=tt.time*1000+tt.millitm;
if you do this, you have the time in millisec in mytime as a start time
youse the same routinme sometimes else with another long variable and
the
difference is the ellapsed time.
I don“t know, if it helps you!
Best wishes
Werner
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.