From: Young Fan Newsgroups: comp.os.msdos.djgpp Subject: Re: Timing Date: Mon, 05 Jul 1999 09:18:43 -0400 Organization: Nortel Lines: 49 Message-ID: <3780B0B3.CE964094@hotmail.com> References: <377CC7E6 DOT EB82B079 AT hotmail DOT com> NNTP-Posting-Host: pwdld0av.ca.nortel.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.03 [en] (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, Thanks for your help. I've been trying to solve this problem for a whole week. There are very few comments in the DGJPP include files, so I was wondering if you tell me how to use both the uclock and the timestamp counter. This is what I found for uclock in sys/time.h: #include typedef long long uclock_t; #define UCLOCKS_PER_SEC 1193180 int gettimeofday(struct timeval *_tp, struct timezone *_tzp); unsigned long rawclock(void); int select(int _nfds, fd_set *_readfds, fd_set *_writefds, fd_set *_exceptfds, struct timeval *_timeout); int settimeofday(struct timeval *_tp, ...); uclock_t uclock(void); Would I still run into problems with Windows about this if I restarted in MS-DOS mode? If the uclock doesn't work, how would I use the CPU's timestamp counter? Thanks a lot. Young Fan wrote: > > Hi, > > Would someone know how to use setitimer() and getitimer()? I need to > time how long it takes (to microsecond accuracy if possible, but at > least millisecond accuracy) to go through a certain for-loop. > > Here's what's in include\sys\time.h: > > struct itimerval { > struct timeval it_interval; /* timer interval */ > struct timeval it_value; /* current value */ > }; > int getitimer(int _which, struct itimerval *_value); > int setitimer(int _which, struct itimerval *_value, struct itimerval > *_ovalue); > > What is _which and what am I supposed to put there? > > I basically need to measure the elapsed time during part of the program, > without actually pausing program execution like sleep() does. > > Thanks!