delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/03/06:45:27

From: "Andris Pavenis" <pavenis AT acad DOT latnet DOT lv>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A question about DJGPP's clock?()
Date: Tue, 03 Mar 1998 05:35:58 -0600
Organization: Deja News - The Leader in Internet Discussion
Lines: 44
Message-ID: <6dgpu3$qru$1@nnrp1.dejanews.com>
References: <34FB744B DOT D26C1712 AT concentric DOT net>
NNTP-Posting-Host: postnews.dejanews.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <34FB744B DOT D26C1712 AT concentric DOT net>,
  "D. Huizenga" <skis AT concentric DOT net> wrote:
>
> Hi,
>
>  I have a quick question about clock().  Does DJGPP have a way to
> increase the 'resolution' of the time returned by this function? I don't
> care if it's standard/portable..  If something similar to this can be
> done with Allegro, that would be good to. Thanks for your help.
>
> --

If You really don't nead portability and You using PENTIUM OR BETTER
CPU then why not to use Pentium timestamp counter. It is very easy to
read it.

#define RDTSC(_dst) \
__asm__("
     .byte 0x0F,0x31
     movl %%edx,(%%edi)
     movl %%eax,4(%%edi)"\
: : "D" (_dst) : "eax", "edx", "edi")



long long  A; RDTSC(&A);

should get time in variable A; Note that timestamp counter counts
CPU clocks so You need to divide result with CPU clock frequency to
get seconds. This code should work also under Linux.

This macro is a fragment from post to this mailing list about 1.5 years
ago.

Subject: P5 Profiling
   Date: Fri, 6 Sep 1996 11:02:27 +0000
  From:  "Kevin Baca" <kbaca AT skygames DOT com>
     To: djgpp AT delorie DOT com


Andris Pavenis

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

- Raw text -


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