delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/09/05/00:31:34

Lines: 26
X-Admin: news AT aol DOT com
From: sterten AT aol DOT com (Sterten)
Newsgroups: comp.os.msdos.djgpp
Date: 05 Sep 2001 04:28:44 GMT
Organization: AOL http://www.aol.com
Subject: timing-routine
Message-ID: <20010905002844.18811.00004524@mb-fa.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

why do I sometimes get non-increasing number on consecutive runs
of this routine ? Is there a better way to measure CPU-cycles ?


  #include "stdio.h"

 double timing() {
  long int i=0,j=0;
  double dd=0;
__asm__ __volatile__ ("
        pushl %%eax
        pushl %%edx
        rdtsc
        movl %%eax,%0
        movl %%edx,%1
        popl %%edx
        popl %%eax
        ":"=g"(i),"=g"(j) );
  dd=i*1.0+4294967296.0*j;
  return(dd);}

int main(){
  double d1=0;
  d1=timing();
  printf("rdtsc=%lf\n",d1);
return(0);}

- Raw text -


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