From: gilleta AT lim DOT univ-mrs DOT fr (Bruno Gilleta) Newsgroups: comp.os.msdos.djgpp Subject: Re: exact timming Date: 12 Feb 1997 10:30:20 GMT Organization: UNIVERSITE MARSEILLE Lines: 55 Message-ID: <5ds63s$7im@newsup.univ-mrs.fr> References: NNTP-Posting-Host: pento.esil.univ-mrs.fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Indrek Mandre wrote: > >On Tue, 11 Feb 1997, Jan Hubicka wrote: > >> I sent letter before..but there was some problemw with net.. >> I need to exactly get time of one part of calculation in XaoS >> (exact to 1/150sec) In unix gettimeofday works ok..but at dos it is exact >> just to 1/18.2sec >> How can I do this.. >> In case only way is to increase timer speed and do interrupt handler with >> counter please send me some code if possible.. > >I have the same problem. Also when I use setitimer to call alarm I can't >set it to work more than 10 times in second. In linux 100 times and I >think in all other UNIXes at least same. Gettimeofday working sucks. >And my signal handler gets called only 10 times in second. Is there >anything to do to make it work better? Is it a bug in DJGPP? I think it >should work better and be compatible with UNIXes or at least Linux. Does >usleep also work so, does it only use 1/18 second delays? It works >sometimes strange. >Any comments? A good way to time a program is to use the getrusage function wich works well on both unix gcc and msdos djgpp : #include #include struct rusage t1, t2; double cputime() { getrusage(RUSAGE_SELF, &t2); return (t2.ru_utime.tv_sec - t1.ru_utime.tv_sec) + (t2.ru_utime.tv_usec - t1.ru_utime.tv_usec) / 1.0e6; } void initcputime() { getrusage(RUSAGE_SELF, &t1); } Regards. Bruno. --- Bruno GILLETA Laboratoire d'Informatique de Marseille NH 3.2.1 (U) D Gilleta-VF HP:120 Pw:55 AC:-11 N [+ )++ P- S+ ?D p+ $+ t s++ W-- E? PS? ?PP G- C-- I+ @W? N b X-- So+ Sp+ !sb wb?