www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/12/12:04:54

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: <Pine DOT LNX DOT 3 DOT 95 DOT 970211182355 DOT 229A-100000 AT warp DOT edu DOT ee>
NNTP-Posting-Host: pento.esil.univ-mrs.fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Indrek Mandre <indrek AT warp DOT edu DOT ee> 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 <sys/time.h>
#include <sys/resource.h>

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? 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019